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

June 16 deploy #69

Merged
merged 10 commits into from
Jun 16, 2021
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -50,6 +50,7 @@ The following config parameters are supported, they are defined in `config/defau
|AUTH0_CLIENT_ID| The Auth0 ClientID for generating Machine-to-machine token ||
|AUTH0_CLIENT_SECRET| The Auth0 Client Secret for generating Machine-to-machine token ||
|ROLE_ID_COPILOT| The registered role id of copilot ||
|ROLE_ID_ITERATIVE_REVIEWER| The registered role id of iterative reviewer ||
|ROLE_ID_SUBMITTER| The registered role id of submitter ||
|TYPE_ID_TASK| The registered type id of a task ||
|DEFAULT_TIMELINE_TEMPLATE_ID| The default timeline template id ||
1 change: 1 addition & 0 deletions config/default.js
Original file line number Diff line number Diff line change
@@ -64,6 +64,7 @@ module.exports = {
WEBSITE_SECURE: process.env.WEBSITE_SECURE || 'https://topcoderx.topcoder-dev.com',

ROLE_ID_COPILOT: process.env.ROLE_ID_COPILOT || 'cfe12b3f-2a24-4639-9d8b-ec86726f76bd',
ROLE_ID_ITERATIVE_REVIEWER: process.env.ROLE_ID_ITERATIVE_REVIEWER || 'f6df7212-b9d6-4193-bfb1-b383586fce63',
ROLE_ID_SUBMITTER: process.env.ROLE_ID_SUBMITTER || '732339e7-8e30-49d7-9198-cccf9451e221',
TYPE_ID_TASK: process.env.TYPE_ID_TASK || 'ecd58c69-238f-43a4-a4bb-d172719b9f31',
DEFAULT_TIMELINE_TEMPLATE_ID: process.env.DEFAULT_TIMELINE_TEMPLATE_ID || '53a307ce-b4b3-4d6f-b9a1-3741a58f77e6',
1 change: 1 addition & 0 deletions configuration.md
Original file line number Diff line number Diff line change
@@ -35,6 +35,7 @@ The following config parameters are supported, they are defined in `config/defau
|AUTH0_CLIENT_ID| The Auth0 ClientID for generating Machine-to-machine token ||
|AUTH0_CLIENT_SECRET| The Auth0 Client Secret for generating Machine-to-machine token ||
|ROLE_ID_COPILOT| The registered role id of copilot ||
|ROLE_ID_ITERATIVE_REVIEWER| The registered role id of iterative reviewer ||
|ROLE_ID_SUBMITTER| The registered role id of submitter ||
|TYPE_ID_TASK| The registered type id of a task ||
|DEFAULT_TIMELINE_TEMPLATE_ID| The default timeline template id ||
47 changes: 6 additions & 41 deletions models/CopilotPayment.js
Original file line number Diff line number Diff line change
@@ -21,64 +21,29 @@ const schema = new Schema({
required: true
},
project: {
type: String,
index: {
global: true,
rangeKey: 'id',
project: true,
name: 'ProjectIndex'
}
type: String
},
amount: {type: Number, required: true},
description: {type: String, required: true},
challengeId: {
type: Number,
required: false,
index: {
global: true,
rangeKey: 'id',
project: true,
name: 'ChallengeIdIndex'
}
required: false
},
challengeUUID: {
type: String,
required: false,
index: {
global: true,
project: true,
name: 'ChallengeUUIdIndex'
}
required: false
},
closed: {
type: String,
required: true,
default: 'false',
index: {
global: true,
rangeKey: 'id',
project: true,
name: 'ClosedIndex'
}
default: 'false'
},
username: {
type: String,
required: true,
index: {
global: true,
rangeKey: 'id',
project: true,
name: 'UsernameIndex'
}
required: true
},
status: {
type: String,
index: {
global: true,
rangeKey: 'id',
project: true,
name: 'StatusIndex'
}
type: String
}
});

18 changes: 3 additions & 15 deletions models/Issue.js
Original file line number Diff line number Diff line change
@@ -17,33 +17,21 @@ const schema = new Schema({
// From the receiver service
number: {
type: Number,
required: true,
index: {
global: true,
rangeKey: 'id',
project: true,
name: 'NumberIndex'
}
required: true
},
title: {type: String, required: true},
body: {type: String},
prizes: {type: [Number], required: true}, // extracted from title
provider: {
type: String,
required: true,
index: {
global: true,
rangeKey: 'id',
project: true,
name: 'ProviderIndex'
}
required: true
}, // github or gitlab
repositoryId: {
type: Number,
required: true,
index: {
global: true,
rangeKey: 'id',
rangeKey: 'number',
project: true,
name: 'RepositoryIdIndex'
}
9 changes: 6 additions & 3 deletions models/Project.js
Original file line number Diff line number Diff line change
@@ -21,15 +21,18 @@ const schema = new Schema({
title: {type: String, required: true},
tcDirectId: {
type: Number,
required: true
},
repoUrl: {
type: String,
required: true,
index: {
global: true,
rangeKey: 'id',
rangeKey: 'archived',
project: true,
name: 'TcDirectIdIndex'
name: 'RepoUrlIndex'
}
},
repoUrl: {type: String, required: true},
repoId: {type: String, required: false},
rocketChatWebhook: {type: String, required: false},
rocketChatChannelName: {type: String, required: false},
26 changes: 4 additions & 22 deletions models/User.js
Original file line number Diff line number Diff line change
@@ -20,13 +20,7 @@ const schema = new Schema({
},
userProviderId: {
type: Number,
required: true,
index: {
global: true,
rangeKey: 'id',
project: true,
name: 'UsesProviderIdIndex'
}
required: true
},
userProviderIdStr: {
type: String,
@@ -37,32 +31,20 @@ const schema = new Schema({
required: true,
index: {
global: true,
rangeKey: 'id',
rangeKey: 'type',
project: true,
name: 'UsernameIndex'
}
},
role: {
type: String,
required: true,
enum: _.values(constants.USER_ROLES),
index: {
global: true,
project: true,
name: 'RoleIndex',
rangeKey: 'id'
}
enum: _.values(constants.USER_ROLES)
},
type: {
type: String,
required: true,
enum: _.values(constants.USER_TYPES),
index: {
global: true,
rangeKey: 'id',
name: 'TypeIndex',
project: true
}
enum: _.values(constants.USER_TYPES)
},
// gitlab token data
accessToken: {type: String, required: false},
40 changes: 36 additions & 4 deletions models/UserMapping.js
Original file line number Diff line number Diff line change
@@ -23,10 +23,42 @@ const schema = new Schema({
name: 'TopcoderUsernameIndex'
}
},
githubUsername: String,
gitlabUsername: String,
githubUserId: Number,
gitlabUserId: Number
githubUsername: {
type: String,
index: {
global: true,
project: true,
rangKey: 'id',
name: 'GithubUsernameIndex'
}
},
gitlabUsername: {
type: String,
index: {
global: true,
project: true,
rangKey: 'id',
name: 'GitlabUsernameIndex'
}
},
githubUserId: {
type: Number,
index: {
global: true,
project: true,
rangKey: 'id',
name: 'GithubUserIdIndex'
}
},
gitlabUserId: {
type: Number,
index: {
global: true,
project: true,
rangKey: 'id',
name: 'GitlabUserIdIndex'
}
}
});

module.exports = schema;
8 changes: 3 additions & 5 deletions services/EventService.js
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ async function handleEventGracefully(event, data, err) {
// reschedule event
if (event.retryCount < config.RETRY_COUNT) {
logger.debug('Scheduling event for next retry');
const newEvent = { ...event };
const newEvent = {...event};
newEvent.retryCount += 1;
delete newEvent.copilot;
const timeoutKey = setTimeout(async () => {
@@ -79,17 +79,15 @@ async function handleEventGracefully(event, data, err) {
} else if (event.event === 'issue.created') {
if (err.name === 'ProcessorError' && err.statusCode && err.message) {
// comment for challenge creation failed
comment = `[${err.statusCode}]: ${err.message}`
comment = `[${err.statusCode}]: ${err.message}`;
} else {
// comment for challenge creation failed
comment = 'The challenge creation on the Topcoder platform failed. Please contact support to try again';
}
} else if (event.event === 'copilotPayment.add') {
// comment for copilot payment challenge create failed
comment = 'The copilot payment challenge creation on the Topcoder platform failed. Please contact support to try again';
await dbHelper.remove(models.CopilotPayment, {
id: { eq: data.id }
});
await dbHelper.removeCopilotPayment(models.CopilotPayment, data.id);
// we dont need to put comment for copilot payment
return;
}
2 changes: 1 addition & 1 deletion services/GithubService.js
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ function _parseRepoUrl(fullName) {
const results = fullName.split('/');
const repo = results[results.length - 1];
const owner = _(results).slice(0, results.length - 1).join('/');
return { owner, repo };
return {owner, repo};
}

/**
Loading