Skip to content

[PROD] TSJR-365 #708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ install_dependency: &install_dependency
sudo apt install jq
sudo apt install python3-pip
sudo pip3 install awscli --upgrade
sudo pip3 install docker==6.1.3
sudo pip3 install docker-compose
install_deploysuite: &install_deploysuite
name: Installation of install_deploysuite.
Expand Down Expand Up @@ -90,7 +91,6 @@ workflows:
branches:
only:
- dev
- CORE-40

- "build-qa":
context: org-global
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18.19.0
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ You can find sample `.env` files inside the `/docs` directory.
1. 📦 Install npm dependencies

```bash
# export the production AWS credentials to access the topcoder-framework private repos in AWS codeartifact
aws codeartifact login --tool npm --repository topcoder-framework --domain topcoder --domain-owner 409275337247 --region us-east-1 --namespace @topcoder-framework

# install dependencies
yarn install
```

Expand Down
6 changes: 3 additions & 3 deletions src/common/challenge-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,9 @@ class ChallengeHelper {
if (data.prizeSets != null) {
const type = data.prizeSets[0]?.prizes[0]?.type;
if (type === constants.prizeTypes.USD) {
ChallengeHelper.convertPSValuesToCents(data.prizeSets)
ChallengeHelper.convertPSValuesToCents(data.prizeSets);
}

data.prizeSetUpdate = {
prizeSets: [...data.prizeSets],
};
Expand Down Expand Up @@ -489,7 +489,7 @@ class ChallengeHelper {
}
}

static convertPSValuesToCents(prizeSets){
static convertPSValuesToCents(prizeSets) {
prizeSets.forEach((prizeSet) => {
prizeSet.prizes.forEach((prize) => {
prize.amountInCents = new Decimal(prize.value).mul(100).toNumber();
Expand Down
7 changes: 1 addition & 6 deletions src/common/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,6 @@ async function getMembersByHandles(handles) {
* @returns {Object}
*/
async function getStandSkills(ids) {

const queryBatches = [];
const skillIdArg = "&skillId=";
let queryString = "disablePagination=true";
Expand All @@ -1157,15 +1156,11 @@ async function getStandSkills(ids) {
queryBatches.push(queryString);

const skillDataPromises = [];
const token = await m2mHelper.getM2MToken();
for (const batch of queryBatches) {
skillDataPromises.push(
(async () => {
const res = await axios.get(
`${config.API_BASE_URL}/v5/standardized-skills/skills?${batch}`,
{
headers: { Authorization: `Bearer ${token}` },
}
`${config.API_BASE_URL}/v5/standardized-skills/skills?${batch}`
);
return res.data;
})()
Expand Down
8 changes: 2 additions & 6 deletions src/common/s3ParseUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ module.exports = function s3ParseUrl(url) {
}

// http://s3-aws-region.amazonaws.com/bucket/key1/key2
match = decodedUrl.match(
/^https?:\/\/s3-([^.]+).amazonaws.com\/([^/]+)\/?(.*?)$/
);
match = decodedUrl.match(/^https?:\/\/s3-([^.]+).amazonaws.com\/([^/]+)\/?(.*?)$/);
if (match) {
return {
bucket: match[2],
Expand All @@ -40,9 +38,7 @@ module.exports = function s3ParseUrl(url) {

// http://bucket.s3-aws-region.amazonaws.com/key1/key2 or,
// http://bucket.s3.aws-region.amazonaws.com/key1/key2
match = decodedUrl.match(
/^https?:\/\/([^.]+).(?:s3-|s3\.)([^.]+).amazonaws.com\/?(.*?)$/
);
match = decodedUrl.match(/^https?:\/\/([^.]+).(?:s3-|s3\.)([^.]+).amazonaws.com\/?(.*?)$/);
if (match) {
return {
bucket: match[1],
Expand Down
6 changes: 1 addition & 5 deletions src/controllers/AttachmentController.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ const service = require("../services/AttachmentService");
*/
async function createAttachment(req, res) {
const body = _.isArray(req.body) ? req.body : [req.body];
const result = await service.createAttachment(
req.authUser,
req.params.challengeId,
body
);
const result = await service.createAttachment(req.authUser, req.params.challengeId, body);
res.status(HttpStatus.CREATED).send(result);
}

Expand Down
10 changes: 2 additions & 8 deletions src/controllers/ChallengePhaseController.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ async function getPhase(req, res) {
* @param {Object} res the response
*/
async function fullyUpdatePhase(req, res) {
const result = await service.fullyUpdatePhase(
req.params.challengePhaseId,
req.body
);
const result = await service.fullyUpdatePhase(req.params.challengePhaseId, req.body);
res.send(result);
}

Expand All @@ -55,10 +52,7 @@ async function fullyUpdatePhase(req, res) {
* @param {Object} res the response
*/
async function partiallyUpdatePhase(req, res) {
const result = await service.partiallyUpdatePhase(
req.params.challengePhaseId,
req.body
);
const result = await service.partiallyUpdatePhase(req.params.challengePhaseId, req.body);
res.send(result);
}

Expand Down
4 changes: 1 addition & 3 deletions src/controllers/ChallengeTimelineTemplateController.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ async function createChallengeTimelineTemplate(req, res) {
* @param {Object} res the response
*/
async function getChallengeTimelineTemplate(req, res) {
const result = await service.getChallengeTimelineTemplate(
req.params.challengeTimelineTemplateId
);
const result = await service.getChallengeTimelineTemplate(req.params.challengeTimelineTemplateId);
res.send(result);
}

Expand Down
9 changes: 2 additions & 7 deletions src/controllers/HealthController.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,9 @@ async function checkHealth(req, res) {
try {
await service.searchChallengeTypes({ page: 1, perPage: 1 });
} catch (e) {
throw new errors.ServiceUnavailableError(
`There is database operation error, ${e.message}`
);
throw new errors.ServiceUnavailableError(`There is database operation error, ${e.message}`);
}
if (
new Date().getTime() - timestampMS >
Number(config.HEALTH_CHECK_TIMEOUT)
) {
if (new Date().getTime() - timestampMS > Number(config.HEALTH_CHECK_TIMEOUT)) {
throw new errors.ServiceUnavailableError("Database operation is slow.");
}
// there is no error, and it is quick, then return checks run count
Expand Down
4 changes: 1 addition & 3 deletions src/controllers/SupportController.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ const logger = require("../common/logger");
*/
async function createRequest(req, res) {
logger.debug(
`createRequest User: ${JSON.stringify(
req.authUser
)} - Body: ${JSON.stringify(req.body)}`
`createRequest User: ${JSON.stringify(req.authUser)} - Body: ${JSON.stringify(req.body)}`
);
const result = await service.createRequest(req.authUser, req.body);
res.status(HttpStatus.CREATED).send(result);
Expand Down
13 changes: 3 additions & 10 deletions src/controllers/TimelineTemplateController.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ async function createTimelineTemplate(req, res) {
* @param {Object} res the response
*/
async function getTimelineTemplate(req, res) {
const result = await service.getTimelineTemplate(
req.params.timelineTemplateId
);
const result = await service.getTimelineTemplate(req.params.timelineTemplateId);
res.send(result);
}

Expand All @@ -44,10 +42,7 @@ async function getTimelineTemplate(req, res) {
* @param {Object} res the response
*/
async function fullyUpdateTimelineTemplate(req, res) {
const result = await service.fullyUpdateTimelineTemplate(
req.params.timelineTemplateId,
req.body
);
const result = await service.fullyUpdateTimelineTemplate(req.params.timelineTemplateId, req.body);
res.send(result);
}

Expand All @@ -70,9 +65,7 @@ async function partiallyUpdateTimelineTemplate(req, res) {
* @param {Object} res the response
*/
async function deleteTimelineTemplate(req, res) {
const result = await service.deleteTimelineTemplate(
req.params.timelineTemplateId
);
const result = await service.deleteTimelineTemplate(req.params.timelineTemplateId);
res.send(result);
}

Expand Down
10 changes: 4 additions & 6 deletions src/scripts/check-templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ async function main() {
const phases = res.data;
_.each(template.phases, (phase) => {
const phaseInstance = _.find(phases, (p) => p.id === phase.phaseId);
const pred = phase.predecessor
? _.find(phases, (p) => p.id === phase.predecessor)
: null;
const pred = phase.predecessor ? _.find(phases, (p) => p.id === phase.predecessor) : null;
console.log(
`Phase Length: ${phase.defaultDuration / 60 / 60} hrs \t ${
phaseInstance.name
} - Depends on ${pred ? pred.name : "nothing"}`
`Phase Length: ${phase.defaultDuration / 60 / 60} hrs \t ${phaseInstance.name} - Depends on ${
pred ? pred.name : "nothing"
}`
);
});
}
Expand Down
8 changes: 2 additions & 6 deletions src/scripts/seed-tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ Object.keys(models).forEach((modelName) => {
}
try {
const data = require(`./seed/${modelName}.json`);
logger.info(
`Inserting ${get(data, "length")} records in table ${modelName}`
);
logger.info(`Inserting ${get(data, "length")} records in table ${modelName}`);
promises.push(models[modelName].batchPut(data));
} catch (e) {
logger.warn(`No records will be inserted in table ${modelName}`);
Expand All @@ -29,9 +27,7 @@ Object.keys(models).forEach((modelName) => {

Promise.all(promises)
.then(() => {
logger.info(
"All tables have been inserted with the data. The processes is run asynchronously"
);
logger.info("All tables have been inserted with the data. The processes is run asynchronously");
process.exit();
})
.catch((err) => {
Expand Down
8 changes: 2 additions & 6 deletions src/scripts/view-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ const viewData = async (modelName) => {
};

if (process.argv.length === 2) {
logger.info(
`Please provide one of the following table name: [${_.keys(models)}]`
);
logger.info(`Please provide one of the following table name: [${_.keys(models)}]`);
process.exit(1);
} else {
const modelName = process.argv[2];
Expand All @@ -32,9 +30,7 @@ if (process.argv.length === 2) {
process.exit(1);
});
} else {
logger.info(
`Please provide one of the following table name: [${_.keys(models)}]`
);
logger.info(`Please provide one of the following table name: [${_.keys(models)}]`);
process.exit(1);
}
}