Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 48ade0a

Browse files
committedOct 18, 2023
feat: use v5 endpoint for tags
1 parent 4220512 commit 48ade0a

File tree

5 files changed

+36
-6
lines changed

5 files changed

+36
-6
lines changed
 

‎models/Project.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,33 @@ const schema = new Schema({
4141
required: true
4242
},
4343
tags: {
44-
type: String,
44+
type: 'list',
45+
list: [{
46+
type: 'map',
47+
map: {
48+
id: {type: String, required: true},
49+
name: {type: String, required: true}
50+
}
51+
}],
4552
required: true,
46-
default: ''
53+
default: [],
54+
fromDynamo(value) {
55+
if (value.S) {
56+
return value.S;
57+
}
58+
if (value.L) {
59+
return value.L.map((item) => {
60+
if (item.M && item.M.name && item.M.id) {
61+
return {
62+
id: item.M.id.S,
63+
name: item.M.name.S
64+
};
65+
}
66+
return null;
67+
});
68+
}
69+
return [];
70+
}
4771
},
4872
rocketChatWebhook: {type: String, required: false},
4973
rocketChatChannelName: {type: String, required: false},

‎services/ChallengeService.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const dbHelper = require('../utils/db-helper');
2020
* @param {Object} event the event
2121
*/
2222
async function handleChallengeTagsUpdate(event) {
23-
const tags = event.data.tags.split(',');
23+
const tags = event.data.tags.map((tag) => tag.name);
2424
await Promise.all(
2525
event.data.challengeUUIDsList.map(async (challengeUUIDs) => {
2626
if (_.isString(challengeUUIDs)) { // repoUrl
@@ -54,7 +54,12 @@ process.schema = Joi.object().keys({
5454
challengeUUIDsList: Joi.array().items(
5555
Joi.alternatives().try(Joi.string(), Joi.array().items(Joi.string()))
5656
).required(),
57-
tags: Joi.string().required()
57+
tags: Joi.array().items(
58+
Joi.object().keys({
59+
id: Joi.string().required(),
60+
name: Joi.string().required()
61+
})
62+
).required()
5863
}).required(),
5964
retryCount: Joi.number().integer().default(0).optional()
6065
});

‎services/CopilotPaymentService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ async function handlePaymentAdd(event, payment) {
194194
const newChallenge = {
195195
name: challengeTitle,
196196
projectId: project.tcDirectId,
197-
tags: !!project.tags ? project.tags.split(',') : [],
197+
tags: project.tags ? project.tags.map((tag) => tag.name) : [],
198198
detailedRequirements: challengeRequirements,
199199
prizes: [payment.amount],
200200
reviewType: 'INTERNAL'

‎services/IssueService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ async function handleIssueCreate(event, issue, forceAssign = false) {
635635
issue.challengeUUID = await topcoderApiHelper.createChallenge({
636636
name: issue.title,
637637
projectId,
638-
tags: project.tags ? project.tags.split(',') : [],
638+
tags: project.tags ? project.tags.map((tag) => tag.name) : [],
639639
detailedRequirements: issue.body,
640640
prizes: issue.prizes
641641
});

‎utils/db-helper.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ async function acquireLockOnUser(userId, lockId, ttl) {
490490
}
491491
});
492492
}
493+
493494
/**
494495
* Release lock on user
495496
* @param {String} id ID of the user

0 commit comments

Comments
 (0)
This repository has been archived.