Skip to content

Commit 3351779

Browse files
authored
Merge pull request #35 from topcoder-platform/issues-99
Issues-99, issues-88, issues-94
2 parents cfd8393 + 8c1dfcc commit 3351779

File tree

10 files changed

+319
-60
lines changed

10 files changed

+319
-60
lines changed

config/template.json

Lines changed: 172 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,91 @@
1818
"type": "secret"
1919
},
2020
"categories": [
21-
{
22-
"name": "Code Documents",
23-
"urlcode": "${ challenge.id }-documents",
24-
"discussions": [
25-
{
26-
"title": "Challenge Overview",
27-
"body": "<a href='<%- challenge.url %>'><%- challenge.name %></a><br/><ul><% _.forEach(challenge.prizeSets, function(prizeSet) { %><li><%- prizeSet.type %>: <% _.forEach(prizeSet.prizes, function(prize) { %><%- prize.value %>$ <% }) %></li> <% }); %></ul>",
28-
"announce": 1,
29-
"closed": 1
30-
},
31-
{
32-
"title": "Base Code",
33-
"body": "See attached.",
34-
"announce": 0,
35-
"closed": 0
36-
},
37-
{
38-
"title": "Coding Structure",
39-
"body": "Please see the attached document from the client and make sure you follow the required structure and guidelines. This is a critical requriement.",
40-
"announce": 0,
41-
"closed": 0
42-
},
43-
{
44-
"title": "Please give us feedback on this challenge!",
45-
"body": "Hi Competitors,\n\nAt topcoder, we are always trying to continuously improve how we are running competitions and tasks for our competitors. Part of this involves getting feedback from you on how well our tasks and challenges are being managed.\n\nPlease take 2-3 minutes to fill out this survey. The results will be used to identify areas of improvement, follow on training, procedural changes, etc.",
46-
"announce": 0,
47-
"closed": 0
48-
}
49-
]
50-
},
51-
{
21+
{
22+
"name": "Code Documents",
23+
"urlcode": "${ challenge.id }-documents",
24+
"discussions": [
25+
{
26+
"title": "Challenge Overview",
27+
"body": "<a href='<%- challenge.url %>'><%- challenge.name %></a><br/><ul><% _.forEach(challenge.prizeSets, function(prizeSet) { %><li><%- prizeSet.type %>: <% _.forEach(prizeSet.prizes, function(prize) { %><%- prize.value %>$ <% }) %></li> <% }); %></ul>",
28+
"announce": 1,
29+
"closed": 1
30+
},
31+
{
32+
"title": "Base Code",
33+
"body": "See attached.",
34+
"announce": 0,
35+
"closed": 0
36+
},
37+
{
38+
"title": "Coding Structure",
39+
"body": "Please see the attached document from the client and make sure you follow the required structure and guidelines. This is a critical requriement.",
40+
"announce": 0,
41+
"closed": 0
42+
},
43+
{
44+
"title": "Please give us feedback on this challenge!",
45+
"body": "Hi Competitors,\n\nAt topcoder, we are always trying to continuously improve how we are running competitions and tasks for our competitors. Part of this involves getting feedback from you on how well our tasks and challenges are being managed.\n\nPlease take 2-3 minutes to fill out this survey. The results will be used to identify areas of improvement, follow on training, procedural changes, etc.",
46+
"announce": 0,
47+
"closed": 0
48+
}
49+
]
50+
},
51+
{
52+
"name": "Code Questions",
53+
"urlcode": "${ challenge.id }-questions",
54+
"discussions": [
55+
{
56+
"title": "Welcome!",
57+
"body": "Please read the requirements carefully, we tried to be clear and simple with the specs. However, if you still have questions let me know, I'll be glad to help you.",
58+
"announce": 0,
59+
"closed": 0
60+
}
61+
]
62+
}
63+
]
64+
},
65+
{
66+
"track": "Quality Assurance",
67+
"name": "${ challenge.name }",
68+
"urlcode": "$ { challenge.id }",
69+
"group": {
70+
"name": "${ challenge.name }",
71+
"description": "Welcome to Topcoder ${ challenge.track } challenge!\nPlease post your questions in this chat group, thanks!",
72+
"type": "secret"
73+
},
74+
"categories": [
75+
{
76+
"name": "Code Documents",
77+
"urlcode": "${ challenge.id }-documents",
78+
"discussions": [
79+
{
80+
"title": "Challenge Overview",
81+
"body": "<a href='<%- challenge.url %>'><%- challenge.name %></a><br/><ul><% _.forEach(challenge.prizeSets, function(prizeSet) { %><li><%- prizeSet.type %>: <% _.forEach(prizeSet.prizes, function(prize) { %><%- prize.value %>$ <% }) %></li> <% }); %></ul>",
82+
"announce": 1,
83+
"closed": 1
84+
},
85+
{
86+
"title": "Base Code",
87+
"body": "See attached.",
88+
"announce": 0,
89+
"closed": 0
90+
},
91+
{
92+
"title": "Coding Structure",
93+
"body": "Please see the attached document from the client and make sure you follow the required structure and guidelines. This is a critical requriement.",
94+
"announce": 0,
95+
"closed": 0
96+
},
97+
{
98+
"title": "Please give us feedback on this challenge!",
99+
"body": "Hi Competitors,\n\nAt topcoder, we are always trying to continuously improve how we are running competitions and tasks for our competitors. Part of this involves getting feedback from you on how well our tasks and challenges are being managed.\n\nPlease take 2-3 minutes to fill out this survey. The results will be used to identify areas of improvement, follow on training, procedural changes, etc.",
100+
"announce": 0,
101+
"closed": 0
102+
}
103+
]
104+
},
105+
{
52106
"name": "Code Questions",
53107
"urlcode": "${ challenge.id }-questions",
54108
"discussions": [
@@ -60,7 +114,7 @@
60114
}
61115
]
62116
}
63-
]
117+
]
64118
}
65119
]
66120
},
@@ -69,7 +123,40 @@
69123
"urlcode": "design-forums",
70124
"categories": [
71125
{
72-
"track": "Design"
126+
"track": "Design",
127+
"name": "${ challenge.name }",
128+
"urlcode": "$ { challenge.id }",
129+
"group": {
130+
"name": "${ challenge.name }",
131+
"description": "Welcome to Topcoder ${ challenge.track } challenge!\nPlease post your questions in this chat group, thanks!",
132+
"type": "secret"
133+
},
134+
"discussions": [
135+
{
136+
"title": "Spec Review Discussion",
137+
"body": "Spec Review Discussion",
138+
"announce": 0,
139+
"closed": 0
140+
},
141+
{
142+
"title": "Please give us feedback on this challenge!",
143+
"body": "Hi Competitors,\n\nAt topcoder, we are always trying to continuously improve how we are running competitions and tasks for our competitors. Part of this involves getting feedback from you on how well our tasks and challenges are being managed.\n\nPlease take 2-3 minutes to fill out this survey. The results will be used to identify areas of improvement, follow on training, procedural changes, etc.",
144+
"announce": 0,
145+
"closed": 0
146+
},
147+
{
148+
"title": "Welcome!",
149+
"body": "Please read the requirements carefully, we tried to be clear and simple with the specs. However, if you still have questions let me know, I'll be glad to help you.",
150+
"announce": 0,
151+
"closed": 0
152+
},
153+
{
154+
"title": "Challenge Overview",
155+
"body": "<a href='<%- challenge.url %>'><%- challenge.name %></a><br/><ul><% _.forEach(challenge.prizeSets, function(prizeSet) { %><li><%- prizeSet.type %>: <% _.forEach(prizeSet.prizes, function(prize) { %><%- prize.value %>$ <% }) %></li> <% }); %></ul>",
156+
"announce": 1,
157+
"closed": 1
158+
}
159+
]
73160
}
74161
]
75162
},
@@ -78,7 +165,58 @@
78165
"urlcode": "data-science-forums",
79166
"categories": [
80167
{
81-
"track": "Data Science"
168+
"track": "Data Science",
169+
"name": "${ challenge.name }",
170+
"urlcode": "$ { challenge.id }",
171+
"group": {
172+
"name": "${ challenge.name }",
173+
"description": "Welcome to Topcoder ${ challenge.track } challenge!\nPlease post your questions in this chat group, thanks!",
174+
"type": "secret"
175+
},
176+
"categories": [
177+
{
178+
"name": "Code Documents",
179+
"urlcode": "${ challenge.id }-documents",
180+
"discussions": [
181+
{
182+
"title": "Challenge Overview",
183+
"body": "<a href='<%- challenge.url %>'><%- challenge.name %></a><br/><ul><% _.forEach(challenge.prizeSets, function(prizeSet) { %><li><%- prizeSet.type %>: <% _.forEach(prizeSet.prizes, function(prize) { %><%- prize.value %>$ <% }) %></li> <% }); %></ul>",
184+
"announce": 1,
185+
"closed": 1
186+
},
187+
{
188+
"title": "Base Code",
189+
"body": "See attached.",
190+
"announce": 0,
191+
"closed": 0
192+
},
193+
{
194+
"title": "Coding Structure",
195+
"body": "Please see the attached document from the client and make sure you follow the required structure and guidelines. This is a critical requriement.",
196+
"announce": 0,
197+
"closed": 0
198+
},
199+
{
200+
"title": "Please give us feedback on this challenge!",
201+
"body": "Hi Competitors,\n\nAt topcoder, we are always trying to continuously improve how we are running competitions and tasks for our competitors. Part of this involves getting feedback from you on how well our tasks and challenges are being managed.\n\nPlease take 2-3 minutes to fill out this survey. The results will be used to identify areas of improvement, follow on training, procedural changes, etc.",
202+
"announce": 0,
203+
"closed": 0
204+
}
205+
]
206+
},
207+
{
208+
"name": "Code Questions",
209+
"urlcode": "${ challenge.id }-questions",
210+
"discussions": [
211+
{
212+
"title": "Welcome!",
213+
"body": "Please read the requirements carefully, we tried to be clear and simple with the specs. However, if you still have questions let me know, I'll be glad to help you.",
214+
"announce": 0,
215+
"closed": 0
216+
}
217+
]
218+
}
219+
]
82220
}
83221
]
84222
}
@@ -89,7 +227,6 @@
89227
},
90228
{
91229
"name": "News, Programs & Events Discussions"
92-
93230
}
94231
]
95232
}

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ services:
1717
KAFKA_ADVERTISED_HOST_NAME: localhost
1818
KAFKA_ADVERTISED_PORT: 9092
1919
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
20-
KAFKA_CREATE_TOPICS: "challenge.notification.create:1:1,challenge.notification.events:1:1,challenge.action.resource.create:1:1,challenge.action.resource.delete:1:1"
20+
KAFKA_CREATE_TOPICS: "challenge.notification.create:1:1,challenge.notification.update:1:1,challenge.notification.events:1:1,challenge.action.resource.create:1:1,challenge.action.resource.delete:1:1"

src/constants.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ module.exports = {
99
TOPICS: {
1010
// For challenge creation
1111
CHALLENGE_CREATE_TOPIC: 'challenge.notification.create',
12+
// For challenge update
13+
CHALLENGE_UPDATE_TOPIC: 'challenge.notification.update',
1214
// For member registrations and de-registrations
1315
CHALLENGE_NOTIFICATION_TOPIC: 'challenge.notification.events',
1416
// For co-pilots,PMs,etc.
@@ -37,6 +39,9 @@ module.exports = {
3739
INVITE: 'invite',
3840
KICK: 'kick'
3941
},
42+
TOPCODER: {
43+
ROLE_COPILOT : 'copilot'
44+
},
4045
VANILLA: {
4146
CHALLENGES_FORUM: 'Challenges Forums',
4247
CATEGORY_DISPLAY_STYLE: {

src/modules/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const createChallenge = require('./create_challenge')
2+
const updateChallenge = require('./update_challenge')
23
const userManagement = require('./user_management')
34

45
module.exports = {
5-
kafkaModules: [createChallenge, userManagement]
6+
kafkaModules: [createChallenge, updateChallenge, userManagement]
67
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const config = require('config')
2+
const util = require('util')
3+
const logger = require('../../utils/logger.util')
4+
const { updateVanillaGroup } = require('../../services/vanilla')
5+
const { processPayload } = require('./helpers')
6+
7+
const services = []
8+
9+
if (config.VANILLA_ENABLED) {
10+
services.push(updateVanillaGroup)
11+
}
12+
13+
/**
14+
* Handle a set of messages from the Kafka topic
15+
* @param {Array} messageSet
16+
* @param {String} topic
17+
*/
18+
async function handler (messageSet, topic) {
19+
if (services.length === 0) {
20+
logger.warn('No enabled services to handle messages')
21+
return
22+
}
23+
for (const item of messageSet) {
24+
const challenge = processPayload(item, topic)
25+
for (const service of services) {
26+
await service(challenge)
27+
.catch(err => {
28+
logger.error(util.inspect(err))
29+
})
30+
}
31+
}
32+
}
33+
34+
module.exports = handler
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const config = require('config')
2+
const _ = require('lodash')
3+
4+
/**
5+
* Processes a payload from the topic, to be consumed by the handler
6+
* @param {Object} payload
7+
*/
8+
function processPayload (payload, topic) {
9+
// Set the url of the challenge
10+
payload.url = `${config.TOPCODER.ROOT_URL}/challenges/${payload.id}`
11+
return payload
12+
}
13+
14+
module.exports = {
15+
processPayload
16+
}

src/modules/update_challenge/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const Kafka = require('no-kafka')
2+
const constants = require('../../constants')
3+
const handler = require('./handler')
4+
5+
module.exports = {
6+
topics: [constants.KAFKA.TOPICS.CHALLENGE_UPDATE_TOPIC],
7+
handler: handler,
8+
options: {
9+
time: Kafka.LATEST_OFFSET
10+
}
11+
}

0 commit comments

Comments
 (0)