Skip to content

Commit e215e9c

Browse files
authored
Merge pull request #423 from topcoder-platform/hotfix/es-skills
[Hotfix] [PROD] es skills
2 parents d70a183 + 1c24d2a commit e215e9c

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/events/projects/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ const indexProject = Promise.coroutine(function* (logger, msg) { // eslint-disab
4141
// removes non required fields from phase objects
4242
data.phases = data.phases.map(phase => _.omit(phase, ['deletedAt', 'deletedBy']));
4343
}
44+
// TEMPORARY FIX: should fix ES mapping instead and reindex all the projects instead
45+
if (typeof _.get(data, 'details.taasDefinition.team.skills') !== 'string') {
46+
_.set(data, 'details.taasDefinition.team.skills', '');
47+
}
4448
// add the record to the index
4549
const result = yield eClient.index({
4650
index: ES_PROJECT_INDEX,
@@ -91,6 +95,10 @@ const projectUpdatedHandler = Promise.coroutine(function* (logger, msg, channel)
9195
// first get the existing document and than merge the updated changes and save the new document
9296
const doc = yield eClient.get({ index: ES_PROJECT_INDEX, type: ES_PROJECT_TYPE, id: data.original.id });
9397
const merged = _.merge(doc._source, data.updated); // eslint-disable-line no-underscore-dangle
98+
// TEMPORARY FIX: should fix ES mapping instead and reindex all the projects instead
99+
if (typeof _.get(merged, 'details.taasDefinition.team.skills') !== 'string') {
100+
_.set(merged, 'details.taasDefinition.team.skills', '');
101+
}
94102
// update the merged document
95103
yield eClient.update({
96104
index: ES_PROJECT_INDEX,
@@ -173,6 +181,10 @@ async function projectUpdatedKafkaHandler(app, topic, payload) {
173181
try {
174182
const doc = await eClient.get({ index: ES_PROJECT_INDEX, type: ES_PROJECT_TYPE, id: previousValue.id });
175183
const merged = _.merge(doc._source, project.get({ plain: true })); // eslint-disable-line no-underscore-dangle
184+
// TEMPORARY FIX: should fix ES mapping instead and reindex all the projects instead
185+
if (typeof _.get(merged, 'details.taasDefinition.team.skills') !== 'string') {
186+
_.set(merged, 'details.taasDefinition.team.skills', '');
187+
}
176188
// update the merged document
177189
await eClient.update({
178190
index: ES_PROJECT_INDEX,

src/routes/admin/project-index-create.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ module.exports = [
9797
projectResponses.map((p) => {
9898
if (p) {
9999
body.push({ index: { _index: indexName, _type: docType, _id: p.id } });
100+
// TEMPORARY FIX: should fix ES mapping instead and reindex all the projects instead
101+
if (typeof _.get(p, 'details.taasDefinition.team.skills') !== 'string') {
102+
_.set(p, 'details.taasDefinition.team.skills', '');
103+
}
100104
body.push(p);
101105
}
102106
// dummy return

0 commit comments

Comments
 (0)