Skip to content

Commit fe9ed92

Browse files
authored
Merge pull request #693 from topcoder-platform/dev
feat: add payments attribute in challenge object
2 parents 2d4e092 + 3a1893f commit fe9ed92

File tree

6 files changed

+521
-486
lines changed

6 files changed

+521
-486
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ workflows:
9090
branches:
9191
only:
9292
- dev
93-
- PLAT-3614
93+
- PLAT-3491
9494

9595
- "build-qa":
9696
context: org-global

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
"dependencies": {
4343
"@grpc/grpc-js": "^1.8.12",
4444
"@opensearch-project/opensearch": "^2.2.0",
45-
"@topcoder-framework/domain-challenge": "^v0.23.1-PLAT-3614.0",
46-
"@topcoder-framework/lib-common": "^v0.23.1-PLAT-3614.0",
45+
"@topcoder-framework/domain-challenge": "^0.24.0",
46+
"@topcoder-framework/lib-common": "^0.24.0",
4747
"aws-sdk": "^2.1145.0",
4848
"axios": "^0.19.0",
4949
"axios-retry": "^3.4.0",

src/common/project-helper.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ class ProjectHelper {
6969
: null;
7070

7171
if (markup && markup > 0) {
72-
// Change int returned from api to decimal
73-
markup = markup / 100;
72+
markup = (markup * 100) / 10000;
7473
}
7574
return {
7675
billingAccountId: _.get(res, "data.tcBillingAccountId", null),

src/services/ChallengeService.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,10 @@ async function searchChallenges(currentUser, criteria) {
833833
if (element.status !== constants.challengeStatuses.Completed) {
834834
_.unset(element, "winners");
835835
}
836+
// TODO: in the long run we wanna do a finer grained filtering of the payments
837+
if (!_hasAdminRole && !_.get(currentUser, "isMachine", false)) {
838+
_.unset(element, "payments");
839+
}
836840
});
837841

838842
return { total, page, perPage, result };
@@ -968,6 +972,11 @@ async function createChallenge(currentUser, challenge, userToken) {
968972

969973
if (_.get(type, "isTask")) {
970974
_.set(challenge, "task.isTask", true);
975+
// this is only applicable for WorkType: Gig, i.e., Tasks created from Salesforce
976+
if (challenge.billing != null && challenge.billing.clientBillingRate != null) {
977+
_.set(challenge, "billing.clientBillingRate", challenge.billing.clientBillingRate);
978+
}
979+
971980
if (_.isUndefined(_.get(challenge, "task.isAssigned"))) {
972981
_.set(challenge, "task.isAssigned", false);
973982
}
@@ -1109,6 +1118,7 @@ createChallenge.schema = {
11091118
.keys({
11101119
billingAccountId: Joi.string(),
11111120
markup: Joi.number().min(0).max(100),
1121+
clientBillingRate: Joi.number().min(0).max(100),
11121122
})
11131123
.unknown(true),
11141124
task: Joi.object().keys({
@@ -1236,12 +1246,7 @@ async function getPhasesAndPopulate(data) {
12361246
* @returns {Object} the challenge with given id
12371247
*/
12381248
async function getChallenge(currentUser, id, checkIfExists) {
1239-
// get challenge from Elasticsearch
12401249
let challenge;
1241-
// logger.warn(JSON.stringify({
1242-
// index: config.get('ES.ES_INDEX'),
1243-
// _id: id
1244-
// }))
12451250
try {
12461251
if (config.get("ES.OPENSEARCH") == "true") {
12471252
challenge = (
@@ -1301,6 +1306,11 @@ async function getChallenge(currentUser, id, checkIfExists) {
13011306
_.unset(challenge, "winners");
13021307
}
13031308

1309+
// TODO: in the long run we wanna do a finer grained filtering of the payments
1310+
if (!hasAdminRole(currentUser) && !_.get(currentUser, "isMachine", false)) {
1311+
_.unset(challenge, "payments");
1312+
}
1313+
13041314
return challenge;
13051315
}
13061316
getChallenge.schema = {
@@ -1896,6 +1906,7 @@ async function updateChallenge(currentUser, challengeId, data) {
18961906
}
18971907

18981908
const updatedChallenge = await challengeDomain.lookup(getLookupCriteria("id", challengeId));
1909+
18991910
await indexChallengeAndPostToKafka(updatedChallenge, track, type);
19001911

19011912
if (updatedChallenge.legacy.selfService) {

src/services/ChallengeTypeService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const challengeTypeDomain = new ChallengeTypeDomain(
2424
/**
2525
* Search challenge types
2626
* @param {Object} criteria the search criteria
27-
* @returns {Object} the search result
27+
* @returns {Promise<Object>} the search result
2828
*/
2929
async function searchChallengeTypes(criteria) {
3030
const scanCriteria = getScanCriteria(_.omit(criteria, ["page", "perPage"]));

0 commit comments

Comments
 (0)