Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 868f23a

Browse files
committed
feat: use v5 endpoint for tags
1 parent 4220512 commit 868f23a

File tree

5 files changed

+25
-9
lines changed

5 files changed

+25
-9
lines changed

models/Project.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,21 @@ const schema = new Schema({
4040
type: Number,
4141
required: true
4242
},
43-
tags: {
44-
type: String,
45-
required: true,
46-
default: ''
47-
},
43+
tags: [
44+
String,
45+
{
46+
type: Array,
47+
schema: [{
48+
type: Object,
49+
schema: {
50+
id: String,
51+
name: String
52+
}
53+
}],
54+
required: true,
55+
default: []
56+
}
57+
],
4858
rocketChatWebhook: {type: String, required: false},
4959
rocketChatChannelName: {type: String, required: false},
5060
archived: {type: String, required: true},

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)