Skip to content

Commit 9221f60

Browse files
committed
Merge branch 'develop' into PM-2394
2 parents 86d4dc4 + 806c174 commit 9221f60

File tree

10 files changed

+224
-68
lines changed

10 files changed

+224
-68
lines changed

.circleci/config.yml

Lines changed: 40 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -48,45 +48,44 @@ build_docker_image: &build_docker_image
4848
./build.sh
4949
no_output_timeout: 20m
5050

51-
build_steps: &build_steps
52-
# Initialization.
53-
- checkout
54-
- setup_remote_docker
55-
- run: *install_dependency
56-
- run: *install_deploysuite
57-
# Restoration of node_modules from cache.
58-
# - restore_cache: *restore_cache_settings_for_build
59-
# Build of Docker image.
60-
- run:
61-
name: "configuring environment"
62-
command: |
63-
./awsconfiguration.sh ${DEPLOY_ENV}
64-
source awsenvconf
65-
./psvar-processor.sh -t appenv -p /config/${APPNAME}/buildvar
66-
source buildvar_env
67-
# ./buildenv.sh -e ${DEPLOY_ENV} -b dev_communityapp_buildvar,dev_communityapp_deployvar -l dev_communityapp_buildvar_ps
68-
- run: *build_docker_image
69-
# Caching node modules.
70-
# - save_cache: *save_cache_settings
71-
# Deployment.
72-
- deploy:
73-
name: Running MasterScript
74-
command: |
75-
source awsenvconf
76-
# source buildenvvar
77-
./psvar-processor.sh -t appenv -p /config/${APPNAME}/deployvar
78-
source deployvar_env
79-
./master_deploy.sh -d ECS -e $DEPLOY_ENV -t latest -j /config/${APPNAME}/appvar -i ${APPNAME} -p FARGATE
80-
# ./master_deploy.sh -d ECS -e DEV -t latest -s dev_communityapp_taskvar -i communityapp -p FARGATE
81-
if [ "${DEPLOY_ENV}" = "PROD" ];
82-
then
83-
# Executing plan
84-
curl --request POST \
85-
--url https://circleci.com/api/v2/project/github/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pipeline \
86-
--header "Circle-Token: ${CIRCLE_TOKEN}" \
87-
--header 'content-type: application/json' \
88-
--data '{"branch":"'"$CIRCLE_BRANCH"'","parameters":{"run_smoketesting":true , "run_performancetesting":false, "run_basedeployment": false}}'
89-
fi
51+
build_steps: &build_steps # Initialization.
52+
- checkout
53+
- setup_remote_docker
54+
- run: *install_dependency
55+
- run: *install_deploysuite
56+
# Restoration of node_modules from cache.
57+
# - restore_cache: *restore_cache_settings_for_build
58+
# Build of Docker image.
59+
- run:
60+
name: "configuring environment"
61+
command: |
62+
./awsconfiguration.sh ${DEPLOY_ENV}
63+
source awsenvconf
64+
./psvar-processor.sh -t appenv -p /config/${APPNAME}/buildvar
65+
source buildvar_env
66+
# ./buildenv.sh -e ${DEPLOY_ENV} -b dev_communityapp_buildvar,dev_communityapp_deployvar -l dev_communityapp_buildvar_ps
67+
- run: *build_docker_image
68+
# Caching node modules.
69+
# - save_cache: *save_cache_settings
70+
# Deployment.
71+
- deploy:
72+
name: Running MasterScript
73+
command: |
74+
source awsenvconf
75+
# source buildenvvar
76+
./psvar-processor.sh -t appenv -p /config/${APPNAME}/deployvar
77+
source deployvar_env
78+
./master_deploy.sh -d ECS -e $DEPLOY_ENV -t latest -j /config/${APPNAME}/appvar -i ${APPNAME} -p FARGATE
79+
# ./master_deploy.sh -d ECS -e DEV -t latest -s dev_communityapp_taskvar -i communityapp -p FARGATE
80+
if [ "${DEPLOY_ENV}" = "PROD" ];
81+
then
82+
# Executing plan
83+
curl --request POST \
84+
--url https://circleci.com/api/v2/project/github/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pipeline \
85+
--header "Circle-Token: ${CIRCLE_TOKEN}" \
86+
--header 'content-type: application/json' \
87+
--data '{"branch":"'"$CIRCLE_BRANCH"'","parameters":{"run_smoketesting":true , "run_performancetesting":false, "run_basedeployment": false}}'
88+
fi
9089
9190
jobs:
9291
# Build & Deploy against development backend
@@ -95,7 +94,7 @@ jobs:
9594
environment:
9695
DEPLOY_ENV: "DEV"
9796
LOGICAL_ENV: "dev"
98-
APPNAME: "community-app"
97+
APPNAME: "community-app"
9998
steps: *build_steps
10099

101100
# Build & Deploy against production backend
@@ -107,7 +106,6 @@ jobs:
107106
APPNAME: "community-app"
108107
steps: *build_steps
109108

110-
111109
# Test job for the cases when we do not need deployment. It just rapidly
112110
# installs (updates) app dependencies, and runs tests (ESLint, Stylelint,
113111
# Jest unit-tests).
@@ -123,7 +121,7 @@ jobs:
123121
command: git config --global url."https://git@".insteadOf git://
124122
- run:
125123
name: App npm install
126-
command: npm install
124+
command: npm ci
127125
no_output_timeout: 20m
128126
- save_cache:
129127
key: test-node-modules-{{ checksum "package-lock.json" }}
@@ -181,8 +179,6 @@ workflows:
181179
branches:
182180
only:
183181
- develop
184-
- v6
185-
- PM-2479
186182

187183
- "build-prod":
188184
context: org-global

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ ENV TOPGEAR_ALLOWED_SUBMISSIONS_DOMAINS=$TOPGEAR_ALLOWED_SUBMISSIONS_DOMAINS
165165

166166
RUN npm config set unsafe-perm true
167167
RUN git config --global url."https://git@".insteadOf git://
168-
RUN npm install
168+
RUN npm ci
169169
RUN npm test
170170
RUN npm run build
171171

bin/www

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,14 @@ require('babel-register')({
1010
],
1111
});
1212

13+
/* Provide TextEncoder/TextDecoder in older Node runtimes (e.g. Node 10). */
14+
const { TextDecoder, TextEncoder } = require('util');
15+
if (typeof global.TextEncoder === 'undefined') {
16+
global.TextEncoder = TextEncoder;
17+
}
18+
if (typeof global.TextDecoder === 'undefined') {
19+
global.TextDecoder = TextDecoder;
20+
}
21+
1322
/* Runs the ExpressJS startup script. */
1423
require('../src/server');

package-lock.json

Lines changed: 33 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@
162162
"showdown": "^1.8.6",
163163
"slick-carousel": "^1.8.1",
164164
"supertest": "^3.1.0",
165-
"tc-core-library-js": "github:topcoder-platform/tc-core-library-js#v2.6.3.1",
165+
"tc-core-library-js": "github:topcoder-platform/tc-core-library-js#master",
166166
"tc-ui": "^1.0.12",
167-
"topcoder-react-lib": "github:topcoder-platform/topcoder-react-lib#auth0",
167+
"topcoder-react-lib": "github:topcoder-platform/topcoder-react-lib#develop",
168168
"topcoder-react-ui-kit": "2.0.1",
169169
"topcoder-react-utils": "github:topcoder-platform/topcoder-react-utils#v6",
170170
"turndown": "^4.0.2",

src/shared/components/challenge-detail/Header/index.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,16 @@ export default function ChallengeHeader(props) {
114114
prizeSets,
115115
prizeSet => ((prizeSet && prizeSet.type) || '').toLowerCase() === 'checkpoint',
116116
);
117+
const checkpointPrizeType = _.toUpper(_.get(checkpointPrizes, 'prizes[0].type', 'USD'));
117118
let numberOfCheckpointsPrizes = 0;
118119
let topCheckPointPrize = 0;
119120
if (!_.isEmpty(checkpointPrizes)) {
120121
numberOfCheckpointsPrizes = checkpointPrizes.prizes.length;
121122
topCheckPointPrize = checkpointPrizes.prizes[0].value;
122123
}
124+
const topCheckPointPrizeDisplay = checkpointPrizeType === 'POINT'
125+
? `${topCheckPointPrize}${topCheckPointPrize === 1 ? 'pt' : 'pts'}`
126+
: `$${topCheckPointPrize}`;
123127

124128
const phases = {};
125129
if (allPhases) {
@@ -394,8 +398,7 @@ export default function ChallengeHeader(props) {
394398
<span
395399
styleName={`bonus-highlight ${trackLower}-accent-color`}
396400
>
397-
$
398-
{topCheckPointPrize}
401+
{topCheckPointPrizeDisplay}
399402
</span>
400403
&zwnj;
401404
EACH

src/shared/containers/challenge-detail/index.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import { getService } from 'services/contentful';
5757
import { getSubmissionArtifacts as getSubmissionArtifactsService } from 'services/submissions';
5858
import getReviewSummationsService from 'services/reviewSummations';
5959
import { buildMmSubmissionData, buildStatisticsData } from 'utils/mm-review-summations';
60+
import { appendUtmParamsToUrl } from 'utils/utm';
6061
// import {
6162
// getDisplayRecommendedChallenges,
6263
// getRecommendedTags,
@@ -349,7 +350,11 @@ class ChallengeDetailPageContainer extends React.Component {
349350
} = this.props;
350351
if (!auth.tokenV3) {
351352
const utmSource = communityId || 'community-app-main';
352-
window.location.href = `${config.URL.AUTH}/member?retUrl=${encodeURIComponent(`${window.location.origin}${window.location.pathname}`)}&utm_source=${utmSource}&regSource=challenges`;
353+
window.location.href = appendUtmParamsToUrl(
354+
`${config.URL.AUTH}/member?retUrl=${encodeURIComponent(`${window.location.origin}${window.location.pathname}`)}&regSource=challenges`, {
355+
utm_source: utmSource,
356+
},
357+
);
353358
} else {
354359
// Show security reminder to all registrants
355360
this.setState({

src/shared/services/reviewOpportunities.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { config } from 'topcoder-react-utils';
2+
import { withEstimatedReviewerPayments } from 'utils/reviewOpportunities';
23

34
const v6ApiUrl = config.API.V6;
45

@@ -22,7 +23,10 @@ export default async function getReviewOpportunities(page, pageSize) {
2223
throw new Error(res.statusText);
2324
}
2425

25-
return res.json();
26+
const data = await res.json();
27+
28+
const opportunities = Array.isArray(data) ? data : [];
29+
return opportunities.map(opportunity => withEstimatedReviewerPayments(opportunity));
2630
}
2731

2832
/**
@@ -51,7 +55,7 @@ export async function getDetails(challengeId, opportunityId) {
5155
const challengeData = await challengeRes.json();
5256

5357
return {
54-
...opportunityData.result.content,
58+
...withEstimatedReviewerPayments(opportunityData.result.content),
5559
challenge: challengeData,
5660
};
5761
} catch (err) {

src/shared/utils/reviewOpportunities.js

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,54 @@ import _ from 'lodash';
55
import moment from 'moment';
66
import { REVIEW_OPPORTUNITY_TYPES } from './tc';
77

8+
export const DEFAULT_ESTIMATED_SUBMISSIONS = 2;
9+
10+
export const calculateEstimatedReviewerPayment = (
11+
basePayment,
12+
incrementalPayment,
13+
estimatedSubmissions = DEFAULT_ESTIMATED_SUBMISSIONS,
14+
) => {
15+
const base = _.toNumber(basePayment);
16+
const incremental = _.toNumber(incrementalPayment);
17+
const submissions = _.toNumber(estimatedSubmissions);
18+
19+
if (_.isNaN(base) || _.isNaN(submissions)) {
20+
return null;
21+
}
22+
23+
const incrementalValue = _.isNaN(incremental) ? 0 : incremental;
24+
return base + (submissions * incrementalValue);
25+
};
26+
27+
export const withEstimatedReviewerPayments = (
28+
opportunity,
29+
estimatedSubmissions = DEFAULT_ESTIMATED_SUBMISSIONS,
30+
) => {
31+
if (!opportunity) return opportunity;
32+
33+
const estimatedPayment = calculateEstimatedReviewerPayment(
34+
_.get(opportunity, 'basePayment', _.get(opportunity, 'payments[0].payment')),
35+
_.get(opportunity, 'incrementalPayment', 0),
36+
estimatedSubmissions,
37+
);
38+
39+
if (!_.isNumber(estimatedPayment)) {
40+
return opportunity;
41+
}
42+
43+
const payments = Array.isArray(opportunity.payments)
44+
? opportunity.payments.map(payment => ({
45+
...payment,
46+
payment: estimatedPayment,
47+
}))
48+
: opportunity.payments;
49+
50+
return {
51+
...opportunity,
52+
payments,
53+
};
54+
};
55+
856
/**
957
* Infers open positions using review opportunity details and organizes them by role
1058
*
@@ -14,7 +62,10 @@ import { REVIEW_OPPORTUNITY_TYPES } from './tc';
1462
export const openPositionsByRole = (details) => {
1563
if (!details.payments) return [];
1664

17-
const roleCount = details.payments.length;
65+
const detailsWithPayments = withEstimatedReviewerPayments(details);
66+
const payments = detailsWithPayments.payments || [];
67+
68+
const roleCount = payments.length;
1869

1970
let approved;
2071
if (details.applications && details.openPositions === 1 && roleCount === 2) {
@@ -28,7 +79,7 @@ export const openPositionsByRole = (details) => {
2879
return details.openPositions / roleCount;
2980
};
3081

31-
return details.payments.map(({ role, roleId, payment }) => ({
82+
return payments.map(({ role, roleId, payment }) => ({
3283
role,
3384
roleId,
3485
payment,

0 commit comments

Comments
 (0)