CF synonm access to doc id

This commit is contained in:
Shams mosowi
2020-03-06 09:11:19 +08:00
parent 03741c987b
commit c6c53efa4d
2 changed files with 32 additions and 23 deletions

View File

@@ -18,26 +18,6 @@ const cohort2algoliaKey = (cohort: string) =>
const cohort2region = (cohort: string) =>
cohort.toUpperCase().replace(/\d+.*$/, "");
// const location2region = (location: string) => {
// const _location = location.toUpperCase();
// switch (_location) {
// case "GLOBAL":
// return "GLOBAL";
// case "SYDNEY":
// return "SYD";
// case "LONDON":
// return "LON";
// case "SINGAPORE":
// return "SG";
// case "AMSTERDAM":
// return "AMS";
// case 'OSLO': return 'OSL'
// default:
// break;
// }
// };
const cohort2location = (cohort: string) => {
const _region = cohort2region(cohort);
switch (_region) {
@@ -90,6 +70,21 @@ const config = [
},
],
},
{
name: "icManagement",
groups: [
{
listenerField: "cohort",
synonymField: "region",
transformer: cohort2region,
},
{
listenerField: "cohort",
synonymField: "algoliaKey",
transformer: cohort2algoliaKey,
},
],
},
{
name: "portfolio",
groups: [
@@ -105,10 +100,24 @@ const config = [
},
],
},
{
name: "teams",
groups: [
{
listenerField: "cohort",
synonymField: "region",
transformer: cohort2region,
},
{
listenerField: "id",
synonymField: "ddPage",
transformer: id => `https://firepage.antler.co/DD?id=${id}`,
},
],
},
...cohort2regionCollections([
"hubResources",
"profiles",
"teams",
"sprintSubmissions",
"trackoutApplications",
"portfolioEnquiries",

View File

@@ -36,7 +36,7 @@ const addSynonymOnUpdate = (groups: synonymGroup[]) => (
if (!beforeData || !afterData) {
return false;
}
const updates = synonyms(afterData, groups);
const updates = synonyms({ ...afterData, id: change.after.id }, groups);
if (Object.values(updates).length === 0) {
return false;
} else {
@@ -52,7 +52,7 @@ const addSynonymOnCreate = (groups: synonymGroup[]) => (
if (!docData) {
return false;
}
const updates = synonyms(docData, groups);
const updates = synonyms({ ...docData, id: snapshot.id }, groups);
if (Object.keys(updates).length === 0) {
return false;
} else {