Skip to content

feat: add payments attribute in challenge object #693

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 29 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b70b1a9
fix(deps): update @topcoder-framework packages for bug fixes
rakibansary Sep 23, 2023
77e36f2
fix(deps): update @topcoder-framework packages for bug fixes
rakibansary Sep 23, 2023
355a784
fix(deps): update @topcoder-framework packages for bug fixes
rakibansary Sep 23, 2023
2b0f521
feat: add payment attribute to challenge
rakibansary Oct 1, 2023
3795b38
feat: upgrade @topcoder-framework/domain-challenge to support payment…
rakibansary Oct 2, 2023
1c446cb
feat: include payments in challenge response
rakibansary Oct 2, 2023
28c4041
fix: only transform successful responses
rakibansary Oct 3, 2023
336f6ed
fix: current user check
eisbilir Oct 4, 2023
5ce8162
Merge branch 'dev' into PLAT-3491
rakibansary Oct 5, 2023
c68ceae
Merge branch 'dev' into PLAT-3491
rakibansary Oct 6, 2023
b595cca
update topcoder-framework/domain-challenge to support retry
rakibansary Oct 6, 2023
6940a12
feat: versioned responses via transformer
Oct 18, 2023
ac0dd36
Merge branch 'dev' into PLAT-3491-transformer
Oct 18, 2023
3d0c130
Merge branch 'feature/transfomer' into PLAT-3491-transformer
Oct 18, 2023
8aa77b2
feat: remove route transformer
Oct 18, 2023
a3fefd8
Merge pull request #681 from topcoder-platform/PLAT-3491-transformer
Oct 18, 2023
56323d9
Merge branch 'dev' into PLAT-3491
rakibansary Oct 21, 2023
232dcf8
chore: add logs
rakibansary Oct 23, 2023
a7de55b
fix(headers): change "challenge-api-version" to "app-version" for ver…
rakibansary Oct 23, 2023
efd2b2c
fix: take markup into account when locking/unlocking budget
rakibansary Oct 30, 2023
c905c8e
chore: typo
rakibansary Oct 30, 2023
2dd47f6
fix: typo
rakibansary Oct 30, 2023
5f95820
Merge remote-tracking branch 'origin/dev' into PLAT-3491
eisbilir Nov 1, 2023
bd939a7
Merge branch 'dev' into PLAT-3491
rakibansary Nov 2, 2023
c8fc080
Merge branch 'dev' into PLAT-3491
rakibansary Nov 8, 2023
0cea37c
Merge pull request #691 from topcoder-platform/dev
Nov 9, 2023
0ee1672
fix: preserve precision
rakibansary Nov 12, 2023
390820e
chore: use release version
rakibansary Nov 13, 2023
3a1893f
Merge pull request #692 from topcoder-platform/PLAT-3491
rakibansary Nov 13, 2023
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 @@ -90,7 +90,7 @@ workflows:
branches:
only:
- dev
- PLAT-3614
- PLAT-3491

- "build-qa":
context: org-global
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
"dependencies": {
"@grpc/grpc-js": "^1.8.12",
"@opensearch-project/opensearch": "^2.2.0",
"@topcoder-framework/domain-challenge": "^v0.23.1-PLAT-3614.0",
"@topcoder-framework/lib-common": "^v0.23.1-PLAT-3614.0",
"@topcoder-framework/domain-challenge": "^0.24.0",
"@topcoder-framework/lib-common": "^0.24.0",
"aws-sdk": "^2.1145.0",
"axios": "^0.19.0",
"axios-retry": "^3.4.0",
Expand Down
3 changes: 1 addition & 2 deletions src/common/project-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ class ProjectHelper {
: null;

if (markup && markup > 0) {
// Change int returned from api to decimal
markup = markup / 100;
markup = (markup * 100) / 10000;
}
return {
billingAccountId: _.get(res, "data.tcBillingAccountId", null),
Expand Down
21 changes: 16 additions & 5 deletions src/services/ChallengeService.js
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,10 @@ async function searchChallenges(currentUser, criteria) {
if (element.status !== constants.challengeStatuses.Completed) {
_.unset(element, "winners");
}
// TODO: in the long run we wanna do a finer grained filtering of the payments
if (!_hasAdminRole && !_.get(currentUser, "isMachine", false)) {
_.unset(element, "payments");
}
});

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

if (_.get(type, "isTask")) {
_.set(challenge, "task.isTask", true);
// this is only applicable for WorkType: Gig, i.e., Tasks created from Salesforce
if (challenge.billing != null && challenge.billing.clientBillingRate != null) {
_.set(challenge, "billing.clientBillingRate", challenge.billing.clientBillingRate);
}

if (_.isUndefined(_.get(challenge, "task.isAssigned"))) {
_.set(challenge, "task.isAssigned", false);
}
Expand Down Expand Up @@ -1109,6 +1118,7 @@ createChallenge.schema = {
.keys({
billingAccountId: Joi.string(),
markup: Joi.number().min(0).max(100),
clientBillingRate: Joi.number().min(0).max(100),
})
.unknown(true),
task: Joi.object().keys({
Expand Down Expand Up @@ -1236,12 +1246,7 @@ async function getPhasesAndPopulate(data) {
* @returns {Object} the challenge with given id
*/
async function getChallenge(currentUser, id, checkIfExists) {
// get challenge from Elasticsearch
let challenge;
// logger.warn(JSON.stringify({
// index: config.get('ES.ES_INDEX'),
// _id: id
// }))
try {
if (config.get("ES.OPENSEARCH") == "true") {
challenge = (
Expand Down Expand Up @@ -1301,6 +1306,11 @@ async function getChallenge(currentUser, id, checkIfExists) {
_.unset(challenge, "winners");
}

// TODO: in the long run we wanna do a finer grained filtering of the payments
if (!hasAdminRole(currentUser) && !_.get(currentUser, "isMachine", false)) {
_.unset(challenge, "payments");
}

return challenge;
}
getChallenge.schema = {
Expand Down Expand Up @@ -1896,6 +1906,7 @@ async function updateChallenge(currentUser, challengeId, data) {
}

const updatedChallenge = await challengeDomain.lookup(getLookupCriteria("id", challengeId));

await indexChallengeAndPostToKafka(updatedChallenge, track, type);

if (updatedChallenge.legacy.selfService) {
Expand Down
2 changes: 1 addition & 1 deletion src/services/ChallengeTypeService.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const challengeTypeDomain = new ChallengeTypeDomain(
/**
* Search challenge types
* @param {Object} criteria the search criteria
* @returns {Object} the search result
* @returns {Promise<Object>} the search result
*/
async function searchChallengeTypes(criteria) {
const scanCriteria = getScanCriteria(_.omit(criteria, ["page", "perPage"]));
Expand Down
Loading