Skip to content

Prod release 1.1.0 #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Apr 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
bd0b485
Challenge 30115492 updates - Link Attachments and Tags
Jaouad-Jaghrir Feb 22, 2020
6a82e77
Challenge 30115492 ff - update create attachment validation to allow …
Jaouad-Jaghrir Feb 22, 2020
b3b65de
Merge branch 'develop' into feature/link-attachments
maxceem Feb 28, 2020
346bc82
Remove 'not_analyzed' from handle field in project.members mapping.
gets0ul Mar 10, 2020
f367adf
Fix issue 3723
narekcat Mar 10, 2020
a046f00
Fixes issue 3764.
narekcat Mar 11, 2020
c73fa81
Merge pull request #27 from gets0ul/connect-app_issue3755
maxceem Mar 12, 2020
84fe9db
Merge pull request #28 from narekcat/develop
maxceem Mar 13, 2020
ca2f4be
Merge pull request #30 from narekcat/issue-3764
maxceem Mar 13, 2020
2ebd8a2
Merge branch 'feature/link-attachments' into feature/link-attachments
maxceem Mar 13, 2020
422f4ac
Merge pull request #24 from Schpotsky/feature/link-attachments
maxceem Mar 13, 2020
f475f70
chore: update "package-lock.json
maxceem Mar 13, 2020
448e38a
chore: bump ES API version
maxceem Mar 13, 2020
f2cd76f
merge: "develop" into "hotfix/remove-invite-on-member-create-dev"
maxceem Mar 17, 2020
779fa56
Merge branch 'develop' into hotfix/remove-invite-on-member-create-dev
maxceem Mar 17, 2020
9f8ac02
Merge pull request #34 from topcoder-platform/hotfix/remove-invite-on…
maxceem Mar 17, 2020
2e36fa0
fix: make sure adding member never fails
maxceem Mar 17, 2020
9666d6f
Merge pull request #35 from topcoder-platform/hotfix/remove-invite-on…
maxceem Mar 17, 2020
fb4ac97
Merge branch 'develop' into feature/link-attachments
maxceem Mar 24, 2020
0ce1ef6
feat: remove "invite.hashEmail"
maxceem Mar 24, 2020
e6f98e3
Merge branch 'develop' into feature/link-attachments
maxceem Mar 24, 2020
825973d
Merge pull request #44 from topcoder-platform/feature/link-attachments
Mar 26, 2020
665ae6a
Merge branch 'master' into develop
Apr 2, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = {
esConfig: {
HOST: process.env.ES_HOST || 'localhost:9200',
AWS_REGION: process.env.AWS_REGION || 'us-east-1', // AWS Region to be used if we use AWS ES
API_VERSION: process.env.ES_API_VERSION || '6.7',
API_VERSION: process.env.ES_API_VERSION || '6.8',
ES_PROJECT_INDEX: process.env.ES_PROJECT_INDEX || 'projects',
ES_TIMELINE_INDEX: process.env.ES_TIMELINE_INDEX || 'timelines',
ES_METADATA_INDEX: process.env.ES_METADATA_INDEX || 'metadata',
Expand Down
11 changes: 8 additions & 3 deletions migrations/elasticsearch_sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ function getRequestBody (indexName) {
description: {
type: 'string'
},
filePath: {
path: {
type: 'string'
},
type: {
type: 'string'
},
tags: {
type: 'string'
},
id: {
Expand Down Expand Up @@ -227,8 +233,7 @@ function getRequestBody (indexName) {
type: 'string'
},
handle: {
type: 'string',
index: 'not_analyzed'
type: 'string'
},
id: {
type: 'long'
Expand Down
1,603 changes: 792 additions & 811 deletions package-lock.json

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions src/common/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,29 @@ async function getMemberDetailsByUserIds (userIds) {
}
}

/**
* Populate member with user details
*
* @param {Object} member the member object
* @returns {Object} the member object with details
*/
async function populateMemberWithUserDetails (member) {
try {
const membersDetails = await getMemberDetailsByUserIds([member.userId])
const memberDetails = membersDetails[0]
if (memberDetails) {
logger.debug(`Successfully got user details for member (userId:${member.userId})`)
return _.merge(member, _.pick(memberDetails, 'handle', 'firstName', 'lastName', 'email'))
} else {
throw new Error(`Didn't fine user details for member (userId:${member.userId})`)
}
} catch (err) {
logger.error(`Cannot populate member (userId:${member.userId}) with user details.`)
logger.debug(`Error during populating member (userId:${member.userId}) with user details`, err)
return member
}
}

/**
* Reusable method to generate a function which would remove invite from the project ES document.
*
Expand All @@ -188,5 +211,6 @@ module.exports = {
updateTimelineESPromise,
updateMetadadaESPromise,
getMemberDetailsByUserIds,
populateMemberWithUserDetails,
removeInvitePromise
}
8 changes: 7 additions & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,18 @@ const MILESTONE_TEMPLATE_REFERENCES = {
PRODUCT_TEMPLATE: 'productTemplate'
}

const ATTACHMENT_TYPES = {
'FILE': 'file',
'LINK': 'link'
}

module.exports = {
RESOURCES,
REGEX,
PROJECT_STATUS,
TIMELINE_REFERENCES,
INVITE_STATUS,
PROJECT_MEMBER_ROLE,
MILESTONE_TEMPLATE_REFERENCES
MILESTONE_TEMPLATE_REFERENCES,
ATTACHMENT_TYPES
}
10 changes: 7 additions & 3 deletions src/services/ProcessorServiceAttachment.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const _ = require('lodash')

const logger = require('../common/logger')
const helper = require('../common/helper')
const constants = require('../constants')

/**
* create id schema
Expand All @@ -27,7 +28,8 @@ function updateSchema () {
return createIdSchema().keys({
title: Joi.string().required(),
description: Joi.string().optional().allow(null).allow(''),
allowedUsers: Joi.array().items(Joi.number().integer().positive()).allow(null).default(null)
allowedUsers: Joi.array().items(Joi.number().integer().positive()).allow(null).default(null),
tags: Joi.array().items(Joi.string()).optional().allow(null)
})
}

Expand All @@ -39,8 +41,10 @@ function createSchema () {
return updateSchema().keys({
category: Joi.string().optional().allow(null).allow(''),
size: Joi.number().optional().allow(null),
contentType: Joi.string().required(),
filePath: Joi.string().required()
contentType: Joi.string().optional().allow(null).when('type', { is: constants.ATTACHMENT_TYPES.FILE, then: Joi.string().required() }),
path: Joi.string().required(),
type: Joi.string().valid(_.values(constants.ATTACHMENT_TYPES)),
tags: Joi.array().items(Joi.string()).optional().allow(null)
})
}

Expand Down
3 changes: 3 additions & 0 deletions src/services/ProcessorServiceProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ function createSchema () {
* @return {Promise} promise result
*/
async function create (message) {
const member = await helper.populateMemberWithUserDetails(message.members[0])
message.members = [member]

await client.create({
index: config.get('esConfig.ES_PROJECT_INDEX'),
type: config.get('esConfig.ES_TYPE'),
Expand Down
18 changes: 1 addition & 17 deletions src/services/ProcessorServiceProjectMember.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,7 @@ async function create (message) {
async function updateDocPromise (doc) {
const members = _.isArray(doc._source.members) ? doc._source.members : []
const existingMemberIndex = _.findIndex(members, p => p.id === message.id)// if member does not exists already
let member = message

// try to populate member with user details
// the code should move on, as it's not critical and is only used for searching at the moment
try {
const membersDetails = await helper.getMemberDetailsByUserIds([message.userId])
const memberDetails = membersDetails[0]
if (memberDetails) {
member = _.merge(message, _.pick(memberDetails, 'handle', 'firstName', 'lastName', 'email'))
logger.debug(`Successfully got user details for member (userId:${message.userId})`)
} else {
throw new Error(`Didn't find user details for member (userId:${message.userId})`)
}
} catch (err) {
logger.error(`Cannot populate member (userId:${message.userId}) with user details.`)
logger.debug(`Error during populating member (userId:${message.userId}) with user details`, err)
}
const member = await helper.populateMemberWithUserDetails(message)

if (existingMemberIndex === -1) {
members.push(member)
Expand Down
1 change: 0 additions & 1 deletion src/services/ProcessorServiceProjectMemberInvite.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ function createSchema () {
.email()
.optional()
.allow(null),
hashEmail: Joi.string().optional().allow(null),
status: Joi.any()
.valid(_.values(INVITE_STATUS))
.required()
Expand Down
2 changes: 1 addition & 1 deletion test/data/attachment/project.action.create.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"topic":"project.action.create","originator":"project-api","timestamp":"2019-06-21T04:41:17.702Z","mime-type":"application/json","payload":{"resource":"attachment","createdAt":"2019-06-21T04:41:17.637Z","updatedAt":"2019-06-21T04:41:17.637Z","id":1,"projectId":1,"allowedUsers":null,"createdBy":40051333,"updatedBy":40051333,"title":"first attachment submission","size":null,"category":null,"description":null,"contentType":"application/png","deletedBy":null,"filePath":"projects/1/projects/asdasd.png"}}
{"topic":"project.action.create","originator":"project-api","timestamp":"2019-06-21T04:41:17.702Z","mime-type":"application/json","payload":{"resource":"attachment","createdAt":"2019-06-21T04:41:17.637Z","updatedAt":"2019-06-21T04:41:17.637Z","id":1,"projectId":1,"allowedUsers":null,"createdBy":40051333,"updatedBy":40051333,"title":"first attachment submission","size":null,"category":null,"description":null,"contentType":"application/png","deletedBy":null,"path":"projects/1/projects/asdasd.png","type":"file","tags":["specification","design preview"]}}
2 changes: 1 addition & 1 deletion test/data/attachment/project.action.update.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"topic":"project.action.update","originator":"project-api","timestamp":"2019-06-21T04:41:46.501Z","mime-type":"application/json","payload":{"resource":"attachment","title":"first attachment submission updated","description":"updated project attachment","allowedUsers":null,"updatedBy":40051333,"id":1,"projectId":1}}
{"topic":"project.action.update","originator":"project-api","timestamp":"2019-06-21T04:41:46.501Z","mime-type":"application/json","payload":{"resource":"attachment","title":"first attachment submission updated","description":"updated project attachment","allowedUsers":null,"updatedBy":40051333,"id":1,"projectId":1,"tags":["specification","design preview","billing information"]}}
2 changes: 1 addition & 1 deletion test/data/project.member.invite/project.action.create.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"topic":"project.action.create","originator":"project-api","timestamp":"2019-06-21T04:58:12.671Z","mime-type":"application/json","payload":{"resource":"project.member.invite","createdAt":"2019-06-21T04:58:12.594Z","updatedAt":"2019-06-21T04:58:12.594Z","id":1,"projectId":1,"role":"customer","status":"pending","createdBy":40051334,"updatedBy":40051334,"userId":40051331,"email":"test@topcoder.com","hashEmail":"dummy_value","deletedAt":null,"deletedBy":null}}
{"topic":"project.action.create","originator":"project-api","timestamp":"2019-06-21T04:58:12.671Z","mime-type":"application/json","payload":{"resource":"project.member.invite","createdAt":"2019-06-21T04:58:12.594Z","updatedAt":"2019-06-21T04:58:12.594Z","id":1,"projectId":1,"role":"customer","status":"pending","createdBy":40051334,"updatedBy":40051334,"userId":40051331,"email":"test@topcoder.com","deletedAt":null,"deletedBy":null}}
2 changes: 1 addition & 1 deletion test/data/project.member.invite/project.action.delete.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"topic":"project.action.update","originator":"project-api","timestamp":"2019-06-21T04:59:38.562Z","mime-type":"application/json","payload":{"resource":"project.member.invite","status":"canceled","userId":40051331,"email":"test@topcoder.com","hashEmail":"dummy_value","id":1,"projectId":1}}
{"topic":"project.action.update","originator":"project-api","timestamp":"2019-06-21T04:59:38.562Z","mime-type":"application/json","payload":{"resource":"project.member.invite","status":"canceled","userId":40051331,"email":"test@topcoder.com","id":1,"projectId":1}}
2 changes: 1 addition & 1 deletion test/data/project.member.invite/project.action.update.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"topic":"project.action.update","originator":"project-api","timestamp":"2019-06-21T04:59:38.562Z","mime-type":"application/json","payload":{"resource":"project.member.invite","status":"pending","userId":40051331,"email":"test@topcoder.com","hashEmail":"dummy_value","id":1,"projectId":1}}
{"topic":"project.action.update","originator":"project-api","timestamp":"2019-06-21T04:59:38.562Z","mime-type":"application/json","payload":{"resource":"project.member.invite","status":"pending","userId":40051331,"email":"test@topcoder.com","id":1,"projectId":1}}