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

Commit 7403437

Browse files
authored
Merge pull request #69 from topcoder-platform/develop
June 16 deploy
2 parents 97c3961 + a7bc0a5 commit 7403437

14 files changed

+253
-147
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ The following config parameters are supported, they are defined in `config/defau
5050
|AUTH0_CLIENT_ID| The Auth0 ClientID for generating Machine-to-machine token ||
5151
|AUTH0_CLIENT_SECRET| The Auth0 Client Secret for generating Machine-to-machine token ||
5252
|ROLE_ID_COPILOT| The registered role id of copilot ||
53+
|ROLE_ID_ITERATIVE_REVIEWER| The registered role id of iterative reviewer ||
5354
|ROLE_ID_SUBMITTER| The registered role id of submitter ||
5455
|TYPE_ID_TASK| The registered type id of a task ||
5556
|DEFAULT_TIMELINE_TEMPLATE_ID| The default timeline template id ||

config/default.js

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ module.exports = {
6464
WEBSITE_SECURE: process.env.WEBSITE_SECURE || 'https://topcoderx.topcoder-dev.com',
6565

6666
ROLE_ID_COPILOT: process.env.ROLE_ID_COPILOT || 'cfe12b3f-2a24-4639-9d8b-ec86726f76bd',
67+
ROLE_ID_ITERATIVE_REVIEWER: process.env.ROLE_ID_ITERATIVE_REVIEWER || 'f6df7212-b9d6-4193-bfb1-b383586fce63',
6768
ROLE_ID_SUBMITTER: process.env.ROLE_ID_SUBMITTER || '732339e7-8e30-49d7-9198-cccf9451e221',
6869
TYPE_ID_TASK: process.env.TYPE_ID_TASK || 'ecd58c69-238f-43a4-a4bb-d172719b9f31',
6970
DEFAULT_TIMELINE_TEMPLATE_ID: process.env.DEFAULT_TIMELINE_TEMPLATE_ID || '53a307ce-b4b3-4d6f-b9a1-3741a58f77e6',

configuration.md

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ The following config parameters are supported, they are defined in `config/defau
3535
|AUTH0_CLIENT_ID| The Auth0 ClientID for generating Machine-to-machine token ||
3636
|AUTH0_CLIENT_SECRET| The Auth0 Client Secret for generating Machine-to-machine token ||
3737
|ROLE_ID_COPILOT| The registered role id of copilot ||
38+
|ROLE_ID_ITERATIVE_REVIEWER| The registered role id of iterative reviewer ||
3839
|ROLE_ID_SUBMITTER| The registered role id of submitter ||
3940
|TYPE_ID_TASK| The registered type id of a task ||
4041
|DEFAULT_TIMELINE_TEMPLATE_ID| The default timeline template id ||

models/CopilotPayment.js

+6-41
Original file line numberDiff line numberDiff line change
@@ -21,64 +21,29 @@ const schema = new Schema({
2121
required: true
2222
},
2323
project: {
24-
type: String,
25-
index: {
26-
global: true,
27-
rangeKey: 'id',
28-
project: true,
29-
name: 'ProjectIndex'
30-
}
24+
type: String
3125
},
3226
amount: {type: Number, required: true},
3327
description: {type: String, required: true},
3428
challengeId: {
3529
type: Number,
36-
required: false,
37-
index: {
38-
global: true,
39-
rangeKey: 'id',
40-
project: true,
41-
name: 'ChallengeIdIndex'
42-
}
30+
required: false
4331
},
4432
challengeUUID: {
4533
type: String,
46-
required: false,
47-
index: {
48-
global: true,
49-
project: true,
50-
name: 'ChallengeUUIdIndex'
51-
}
34+
required: false
5235
},
5336
closed: {
5437
type: String,
5538
required: true,
56-
default: 'false',
57-
index: {
58-
global: true,
59-
rangeKey: 'id',
60-
project: true,
61-
name: 'ClosedIndex'
62-
}
39+
default: 'false'
6340
},
6441
username: {
6542
type: String,
66-
required: true,
67-
index: {
68-
global: true,
69-
rangeKey: 'id',
70-
project: true,
71-
name: 'UsernameIndex'
72-
}
43+
required: true
7344
},
7445
status: {
75-
type: String,
76-
index: {
77-
global: true,
78-
rangeKey: 'id',
79-
project: true,
80-
name: 'StatusIndex'
81-
}
46+
type: String
8247
}
8348
});
8449

models/Issue.js

+3-15
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,21 @@ const schema = new Schema({
1717
// From the receiver service
1818
number: {
1919
type: Number,
20-
required: true,
21-
index: {
22-
global: true,
23-
rangeKey: 'id',
24-
project: true,
25-
name: 'NumberIndex'
26-
}
20+
required: true
2721
},
2822
title: {type: String, required: true},
2923
body: {type: String},
3024
prizes: {type: [Number], required: true}, // extracted from title
3125
provider: {
3226
type: String,
33-
required: true,
34-
index: {
35-
global: true,
36-
rangeKey: 'id',
37-
project: true,
38-
name: 'ProviderIndex'
39-
}
27+
required: true
4028
}, // github or gitlab
4129
repositoryId: {
4230
type: Number,
4331
required: true,
4432
index: {
4533
global: true,
46-
rangeKey: 'id',
34+
rangeKey: 'number',
4735
project: true,
4836
name: 'RepositoryIdIndex'
4937
}

models/Project.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@ const schema = new Schema({
2121
title: {type: String, required: true},
2222
tcDirectId: {
2323
type: Number,
24+
required: true
25+
},
26+
repoUrl: {
27+
type: String,
2428
required: true,
2529
index: {
2630
global: true,
27-
rangeKey: 'id',
31+
rangeKey: 'archived',
2832
project: true,
29-
name: 'TcDirectIdIndex'
33+
name: 'RepoUrlIndex'
3034
}
3135
},
32-
repoUrl: {type: String, required: true},
3336
repoId: {type: String, required: false},
3437
rocketChatWebhook: {type: String, required: false},
3538
rocketChatChannelName: {type: String, required: false},

models/User.js

+4-22
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,7 @@ const schema = new Schema({
2020
},
2121
userProviderId: {
2222
type: Number,
23-
required: true,
24-
index: {
25-
global: true,
26-
rangeKey: 'id',
27-
project: true,
28-
name: 'UsesProviderIdIndex'
29-
}
23+
required: true
3024
},
3125
userProviderIdStr: {
3226
type: String,
@@ -37,32 +31,20 @@ const schema = new Schema({
3731
required: true,
3832
index: {
3933
global: true,
40-
rangeKey: 'id',
34+
rangeKey: 'type',
4135
project: true,
4236
name: 'UsernameIndex'
4337
}
4438
},
4539
role: {
4640
type: String,
4741
required: true,
48-
enum: _.values(constants.USER_ROLES),
49-
index: {
50-
global: true,
51-
project: true,
52-
name: 'RoleIndex',
53-
rangeKey: 'id'
54-
}
42+
enum: _.values(constants.USER_ROLES)
5543
},
5644
type: {
5745
type: String,
5846
required: true,
59-
enum: _.values(constants.USER_TYPES),
60-
index: {
61-
global: true,
62-
rangeKey: 'id',
63-
name: 'TypeIndex',
64-
project: true
65-
}
47+
enum: _.values(constants.USER_TYPES)
6648
},
6749
// gitlab token data
6850
accessToken: {type: String, required: false},

models/UserMapping.js

+36-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,42 @@ const schema = new Schema({
2323
name: 'TopcoderUsernameIndex'
2424
}
2525
},
26-
githubUsername: String,
27-
gitlabUsername: String,
28-
githubUserId: Number,
29-
gitlabUserId: Number
26+
githubUsername: {
27+
type: String,
28+
index: {
29+
global: true,
30+
project: true,
31+
rangKey: 'id',
32+
name: 'GithubUsernameIndex'
33+
}
34+
},
35+
gitlabUsername: {
36+
type: String,
37+
index: {
38+
global: true,
39+
project: true,
40+
rangKey: 'id',
41+
name: 'GitlabUsernameIndex'
42+
}
43+
},
44+
githubUserId: {
45+
type: Number,
46+
index: {
47+
global: true,
48+
project: true,
49+
rangKey: 'id',
50+
name: 'GithubUserIdIndex'
51+
}
52+
},
53+
gitlabUserId: {
54+
type: Number,
55+
index: {
56+
global: true,
57+
project: true,
58+
rangKey: 'id',
59+
name: 'GitlabUserIdIndex'
60+
}
61+
}
3062
});
3163

3264
module.exports = schema;

services/EventService.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ async function handleEventGracefully(event, data, err) {
5050
// reschedule event
5151
if (event.retryCount < config.RETRY_COUNT) {
5252
logger.debug('Scheduling event for next retry');
53-
const newEvent = { ...event };
53+
const newEvent = {...event};
5454
newEvent.retryCount += 1;
5555
delete newEvent.copilot;
5656
const timeoutKey = setTimeout(async () => {
@@ -79,17 +79,15 @@ async function handleEventGracefully(event, data, err) {
7979
} else if (event.event === 'issue.created') {
8080
if (err.name === 'ProcessorError' && err.statusCode && err.message) {
8181
// comment for challenge creation failed
82-
comment = `[${err.statusCode}]: ${err.message}`
82+
comment = `[${err.statusCode}]: ${err.message}`;
8383
} else {
8484
// comment for challenge creation failed
8585
comment = 'The challenge creation on the Topcoder platform failed. Please contact support to try again';
8686
}
8787
} else if (event.event === 'copilotPayment.add') {
8888
// comment for copilot payment challenge create failed
8989
comment = 'The copilot payment challenge creation on the Topcoder platform failed. Please contact support to try again';
90-
await dbHelper.remove(models.CopilotPayment, {
91-
id: { eq: data.id }
92-
});
90+
await dbHelper.removeCopilotPayment(models.CopilotPayment, data.id);
9391
// we dont need to put comment for copilot payment
9492
return;
9593
}

services/GithubService.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function _parseRepoUrl(fullName) {
3333
const results = fullName.split('/');
3434
const repo = results[results.length - 1];
3535
const owner = _(results).slice(0, results.length - 1).join('/');
36-
return { owner, repo };
36+
return {owner, repo};
3737
}
3838

3939
/**

0 commit comments

Comments
 (0)