Skip to content

Commit edba966

Browse files
committed
Fix merge conflict and lint errors
2 parents 213e7e9 + 7a494df commit edba966

File tree

16 files changed

+141
-99
lines changed

16 files changed

+141
-99
lines changed

components/ChallengeCard/ChallengeCard.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function ChallengeCard({
3232
const challenge = passedInChallenge;
3333

3434
challenge.isDataScience = false;
35-
if (_.indexOf(challenge.technologies, 'Data Science') > -1) {
35+
if (challenge.technologies.includes('Data Science')) {
3636
challenge.isDataScience = true;
3737
}
3838
challenge.prize = challenge.prizes || [];

components/ChallengeCard/Tooltips/PrizesTooltip/PrizesTooltip.jsx

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/* global
2-
fetch
3-
*/
4-
51
/**
62
* Prizes Tooltip Component.
73
*

components/ChallengeCard/Tooltips/ProgressBarTooltip/ProgressBarTooltip.jsx

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/* global
2-
fetch
3-
*/
4-
51
import moment from 'moment';
62
import _ from 'lodash';
73
/**

components/ChallengeCard/Tooltips/Tooltip/Tooltip.jsx

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/* global
2-
window
3-
*/
4-
51
/**
62
* Tooltip component.
73
*

components/ChallengeCard/Tooltips/TrackAbbreviationTooltip/TrackAbbreviationTooltip.jsx

+17-13
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,40 @@ import Tooltip from '../Tooltip';
1111
import './TrackAbbreviationTooltip.scss';
1212

1313
const DESCRIPTION = {
14-
'APPLICATION_FRONT-END_DESIGN': 'Design UI and front end experiences for apps',
14+
APPLICATION_FRONT_END_DESIGN: 'Design UI and front end experiences for apps',
15+
ARCHITECTURE: 'Architect modules, components, or full applications',
1516
ASSEMBLY_COMPETITION: 'Develop code for a variety of use cases. Rigorous review and final fix process is included.',
17+
BANNERS_OR_ICONS: 'Design UI assets for use in web, mobile, print, and other digital formats',
1618
CODE: 'Develop code for apps, services, etc. Final fixes are not included',
17-
FIRST_2_FINISH: 'Be the first to deliver the solution',
18-
DESIGN_FIRST_2_FINISH: 'Be the first to deliver the solution',
19-
'PRINT/PRESENTATION': 'Design print and presentation assets',
19+
CONCEPTUALIZATION: 'Discover and define user stories and requirements',
20+
DESIGN_FIRST_2_FINISH: 'Be the first to deliver the design solution',
21+
FIRST_2_FINISH: 'Be the first to deliver the development solution',
22+
MARATHON_MATCH: 'Write algorythms to solve complex problems, often for real world issues',
23+
PRINT_OR_PRESENTATION: 'Design print and presentation assets',
24+
SRM: 'Single Round Match - quickly write code to solve algorythm problems head to head against other competitors',
2025
UI_PROTOTYPE_COMPETITION: 'Develop the front end of a UX',
21-
ARCHITECTURE: 'Architect modules, components, or full applications',
2226
WEB_DESIGN: 'Design UI and front end experiences for web experiences',
2327
WEB_DESIGNS: 'Design UI and front end experiences for web experiences',
2428
WIDGET_OR_MOBILE_SCREEN_DESIGN: 'Design UI and front end experiences for mobile',
2529
WIREFRAMES: 'Produce the information architecture for user experiences',
26-
SRM: 'Single Round Match - quickly write code to solve algorythm problems head to head against other competitors',
27-
MARATHON_MATCH: 'Write algorythms to solve complex problems, often for real world issues',
2830
};
2931

3032
const HEADER = {
31-
'APPLICATION_FRONT-END_DESIGN': 'Application Front-End Design (AFED)',
33+
APPLICATION_FRONT_END_DESIGN: 'Application Front-End Design (AFED)',
34+
ARCHITECTURE: 'Architecture (Ar)',
3235
ASSEMBLY_COMPETITION: 'Assembly (As)',
36+
BANNERS_OR_ICONS: 'Banners/Icons (BI)',
3337
CODE: 'Code (Cd)',
38+
CONCEPTUALIZATION: 'Conceptualization (Cn)',
39+
DESIGN_FIRST_2_FINISH: 'Design First2Finish(DF2F)',
3440
FIRST_2_FINISH: 'First2Finish (F2F)',
35-
'PRINT/PRESENTATION': 'Print/Presentation (PP)',
41+
MARATHON_MATCH: 'Marathon Match',
42+
PRINT_OR_PRESENTATION: 'Print/Presentation (PP)',
43+
SRM: 'Single Round Match (SRM)',
3644
UI_PROTOTYPE_COMPETITION: 'UI Prototype (Pr)',
37-
ARCHITECTURE: 'Architecture (Ar)',
3845
WEB_DESIGN: 'Web Design (Wd)',
3946
WEB_DESIGNS: 'Web Design (Wd)',
4047
WIDGET_OR_MOBILE_SCREEN_DESIGN: 'Widget or Mobile Screen Design (Wg)',
41-
SRM: 'Single Round Match (SRM)',
42-
MARATHON_MATCH: 'Marathon Match',
43-
DESIGN_FIRST_2_FINISH: 'Design First2Finish(DF2F)',
4448
};
4549

4650
const TRACK_COLOR_CLASS = {

components/ChallengeCardContainer/ChallengeCardContainer.jsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* global
2-
sessionStorage, window, Math
2+
sessionStorage, Math
33
*/
44

55
/**
@@ -128,7 +128,8 @@ class ChallengeCardContainer extends Component {
128128
Object.keys(filterChallengesStore).map((filterName) => {
129129
let expansionButtion;
130130
const unfilteredChallenges = filterChallengesStore[filterName];
131-
const filteredChallenges = _.filter(unfilteredChallenges, additionalFilter);
131+
const filteredChallenges = _.sortBy(_.filter(unfilteredChallenges, additionalFilter),
132+
sortingFunctionStore[filterSortingStore[filterName]]);
132133
let initialChallenges = unfilteredChallenges;
133134

134135
const challengeCountTotal = filterTotalCountStore[filterName];
@@ -181,6 +182,7 @@ class ChallengeCardContainer extends Component {
181182
fetchItemFinishCallback={fetchCallback}
182183
batchNumber={batchLoadNumber}
183184
filter={additionalFilter}
185+
tempDataFilter={filterName}
184186
sort={sortingFunctionStore[filterSortingStore[filterName]]}
185187
uniqueIdentifier={challengeUniqueIdentifier}
186188
/>

components/ChallengeCardContainer/challengeFilters.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default [
2727
name: 'Open for registration',
2828
check(item) {
2929
const phase = item.currentPhases.filter(d => d.phaseType === 'Registration')[0];
30-
return phase ? phase.phaseStatus === 'Open' : false;
30+
return phase ? phase.phaseStatus === 'Open' && !item.status.startsWith('COMPLETED') : false;
3131
},
3232
sortingOptions: [
3333
'Most recent',
@@ -41,8 +41,9 @@ export default [
4141
info: {
4242
phaseName: 'registration',
4343
},
44+
// v3 end point need to be updated once it is created for open for registration challenges
4445
getApiUrl: (pageIndex, pageSize = 50) => (
45-
`${process.env.API_URL_V2}/challenges/open?pageIndex=${pageIndex}&pageSize=${pageSize}`
46+
`${process.env.API_URL}/challenges/?filter=status%3DActive&offset=${pageIndex * pageSize}&limit=${pageSize}`
4647
),
4748
},
4849
{
@@ -57,11 +58,10 @@ export default [
5758
'Title A-Z',
5859
'Prize high to low',
5960
],
60-
// this api endpoint probably doesn't match the filter criteria exactly
61-
// kept for reference
62-
// getApiUrl: (pageIndex, pageSize = 50) => (
63-
// `http://api.topcoder.com/v2/challenges/active?pageIndex=${pageIndex}&pageSize=${pageSize}`
64-
// ),
61+
// v3 end point need to be updated once it is created for open for ongoing challenges
62+
getApiUrl: (pageIndex, pageSize = 50) => (
63+
`${process.env.API_URL}/challenges/?filter=status%3DActive&offset=${pageIndex * pageSize}&limit=${pageSize}`
64+
),
6565
},
6666
{
6767
name: 'Past challenges',
@@ -73,6 +73,7 @@ export default [
7373
'Title A-Z',
7474
'Prize high to low',
7575
],
76+
// v3 end point need to be updated once it is created for past challenges
7677
getApiUrl: (pageIndex, pageSize = 50) => (
7778
`${process.env.API_URL}/challenges/?filter=status%3DCompleted&offset=${pageIndex * pageSize}&limit=${pageSize}`
7879
),

components/ChallengeCardContainer/generalHelpers.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
/* global
2-
document, fetch, Promise
2+
fetch, Promise
33
*/
44

55
import _ from 'lodash';
66

7+
const COMMUNITIES = {
8+
DEVELOP: 'develop',
9+
DESIGN: 'design',
10+
DATA_SCIENCE: 'datasci',
11+
};
12+
713
// filter out empty challenge buckets, and if currentFilter is passed in,
814
// find the bucket with the filter name and only leave that bucket in
915
export function filterFilterChallengesStore(filterChallengesStore, currentFilter) {
@@ -46,10 +52,15 @@ export function findFilterByName(filterName, filters) {
4652
// return formattedChallenge;
4753
// }
4854

55+
function addCommunity(challenge) {
56+
const updatedChallenge = _.assign({}, challenge);
57+
updatedChallenge.communities = new Set([COMMUNITIES[challenge.track]]);
58+
return updatedChallenge;
59+
}
4960
export function fetchChallenges(getUrl, pageIndex) {
5061
return fetch(getUrl(pageIndex))
5162
.then(response => response.json())
52-
.then(responseJson => responseJson.result.content);
63+
.then(responseJson => responseJson.result.content.map(addCommunity));
5364
}
5465

5566
// check if the category can be expanded beyond initial number to show more challenges

components/ChallengeFilters/ChallengeFilterWithSearch.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ class Filter extends BaseFilter {
3737
return (item) => {
3838
if (!parent(item)) return false;
3939
if (this.query) {
40-
const platforms = item.platforms.join(' ');
41-
const techs = item.technologies.join(' ');
42-
const str = `${item.challengeName} ${platforms} ${techs}`.toLowerCase();
40+
const str = `${item.name} ${item.platforms} ${item.technologies}`.toLowerCase();
4341
if (str.indexOf(this.query.toLowerCase()) < 0) return false;
4442
}
4543
return true;

components/ChallengeFilters/ChallengeFiltersExample.jsx

+60-47
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import _ from 'lodash';
1919
import React, { PropTypes as PT } from 'react';
2020
import Sticky from 'react-stickynode';
2121

22-
import { DESIGN_TRACK, DEVELOP_TRACK } from './ChallengeFilter';
22+
import { DESIGN_TRACK, DEVELOP_TRACK, DATA_SCIENCE_TRACK } from './ChallengeFilter';
2323
import ChallengeFilterWithSearch from './ChallengeFilterWithSearch';
2424
import ChallengeFilters from './ChallengeFilters';
2525
import SideBarFilter, { MODE as SideBarFilterModes } from '../SideBarFilters/SideBarFilter';
@@ -231,67 +231,78 @@ class ChallengeFiltersExample extends React.Component {
231231
/* Normalizes challenge objects received from different API endpoints,
232232
* and adds them to the list of loaded challenges. */
233233
function helper2(response, community) {
234-
return response.json().then(res => res.result.content.forEach((item) => {
234+
return response.json().then((res) => {
235+
const content = res.result ? res.result.content : res.data;
236+
content.forEach((item) => {
235237
/* Only marathon matches, when received from the /data/marathon/challenges
236238
* endpoint, satisfy this. */
237-
if (item.roundId) {
238-
const endTimestamp = new Date(item.endDate).getTime();
239-
_.defaults(item, {
240-
challengeId: item.roundId,
241-
challengeName: item.fullName,
242-
challengeCommunity: 'Data',
243-
challengeType: 'Marathon',
244-
communities: new Set([community]),
245-
currentPhaseEndDate: item.endDate,
246-
currentPhaseName: endTimestamp > Date.now() ? 'Registration' : '',
247-
numRegistrants: item.numberOfRegistrants,
248-
numSubmissions: item.numberOfSubmissions,
249-
platforms: [],
250-
prize: [],
251-
registrationOpen: endTimestamp > Date.now() ? 'Yes' : 'No',
252-
registrationStartDate: item.startDate,
253-
submissionEndDate: item.endDate,
254-
submissionEndTimestamp: endTimestamp,
255-
technologies: [],
256-
totalPrize: 0,
257-
track: 'DATA_SCIENCE',
258-
status: endTimestamp > Date.now() ? 'Active' : 'Completed',
259-
subTrack: 'MARATHON_MATCH',
260-
});
261-
map[item.id] = item;
262-
} else if (item.track === 'SRM') {
263-
/* We don't support SRM yet, so we don't want them around */
264-
} else { /* All challenges from other endpoints have the same format. */
265-
const existing = map[item.id];
266-
if (existing) existing.communities.add(community);
267-
else {
239+
if (item.roundId) {
240+
const endTimestamp = new Date(item.endDate).getTime();
241+
const allphases = [{
242+
challengeId: item.roundId,
243+
phaseType: 'Registration',
244+
phaseStatus: endTimestamp > Date.now() ? 'Open' : 'Close',
245+
scheduledEndTime: item.endDate,
246+
},
247+
];
268248
_.defaults(item, {
249+
id: item.roundId,
250+
name: item.fullName,
251+
challengeCommunity: 'Data',
252+
challengeType: 'Marathon',
253+
allPhases: allphases,
254+
currentPhases: allphases.filter(phase => phase.phaseStatus === 'Open'),
269255
communities: new Set([community]),
256+
currentPhaseName: endTimestamp > Date.now() ? 'Registration' : '',
257+
numRegistrants: item.numberOfRegistrants,
258+
numSubmissions: item.numberOfSubmissions,
270259
platforms: '',
271-
registrationOpen: item.allPhases.filter(d => d.phaseType === 'Registration')[0].phaseStatus === 'Open' ? 'Yes' : 'No',
260+
prizes: [0],
261+
registrationOpen: endTimestamp > Date.now() ? 'Yes' : 'No',
262+
registrationStartDate: item.startDate,
263+
submissionEndDate: item.endDate,
264+
submissionEndTimestamp: endTimestamp,
272265
technologies: '',
273-
track: item.track,
274-
status: item.status,
275-
submissionEndTimestamp: item.submissionEndDate,
276-
subTrack: item.subTrack,
266+
totalPrize: 0,
267+
track: 'DATA_SCIENCE',
268+
status: endTimestamp > Date.now() ? 'ACTIVE' : 'COMPLETED',
269+
subTrack: 'MARATHON_MATCH',
277270
});
278271
map[item.id] = item;
279-
if (item.platforms) {
280-
item.platforms.split(',').forEach(helper1);
281-
}
282-
if (item.technologies) {
283-
item.technologies.split(',').forEach(helper1);
272+
} else if (item.track === 'SRM') {
273+
/* We don't support SRM yet, so we don't want them around */
274+
} else { /* All challenges from other endpoints have the same format. */
275+
const existing = map[item.id];
276+
if (existing) existing.communities.add(community);
277+
else {
278+
_.defaults(item, {
279+
communities: new Set([community]),
280+
platforms: '',
281+
registrationOpen: item.allPhases.filter(d => d.phaseType === 'Registration')[0].phaseStatus === 'Open' ? 'Yes' : 'No',
282+
technologies: '',
283+
submissionEndTimestamp: item.submissionEndDate,
284+
});
285+
map[item.id] = item;
286+
if (item.platforms) {
287+
item.platforms.split(',').forEach(helper1);
288+
}
289+
if (item.technologies) {
290+
item.technologies.split(',').forEach(helper1);
291+
}
284292
}
285293
}
286-
}
287-
}));
294+
});
295+
},
296+
);
288297
}
289298
const api = this.props.config.API_URL;
299+
const api2 = this.props.config.API_URL_V2;
290300
return Promise.all([
291301
/* Fetching of active challenges */
292302
fetch(`${api}/challenges/?filter=track%3Ddesign`).then(res => helper2(res, DESIGN_TRACK)),
293303
fetch(`${api}/challenges/?filter=track%3Ddevelop`).then(res => helper2(res, DEVELOP_TRACK)),
294-
fetch(`${api}/challenges/marathonMatches`),
304+
fetch(`${api2}/data/marathon/challenges/?listType=past&pageSize=100`).then(res => helper2(res, DATA_SCIENCE_TRACK)),
305+
fetch(`${api2}/data/marathon/challenges/?listType=active`).then(res => helper2(res, DATA_SCIENCE_TRACK)),
295306
]).then(() => {
296307
_.forIn(map, item => challenges.push(item));
297308
challenges.sort((a, b) => b.submissionEndDate - a.submissionEndDate);
@@ -307,9 +318,11 @@ class ChallengeFiltersExample extends React.Component {
307318

308319
onFilterByTopFilter(filter, isSidebarFilter) {
309320
const mergedFilter = Object.assign({}, this.state.filter, filter);
310-
const updatedFilter = new SideBarFilter(mergedFilter);
321+
let updatedFilter = new SideBarFilter(mergedFilter);
311322
if (!isSidebarFilter) {
312323
updatedFilter.mode = SideBarFilterModes.CUSTOM;
324+
} else {
325+
updatedFilter = this.state.filter.copySidebarFilterProps(updatedFilter);
313326
}
314327
this.setState({ filter: updatedFilter }, this.saveFiltersToHash.bind(this, updatedFilter));
315328
}

components/ChallengeFilters/FiltersPanel/FilterPanelFilter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class FilterPanelFilter extends BaseFilter {
7272
if (this.subtracks.length && this.subtracks[0]
7373
&& !filterSubtrack.includes(itemSubtrack)) return false;
7474
if (this.startDate && this.startDate.isAfter(item.submissionEndDate)) return false;
75-
if (this.endDate && this.endDate.isBefore(item.postingDate)) return false;
75+
if (this.endDate && this.endDate.isBefore(item.createdAt)) return false;
7676
if (!this.keywords.length || !this.keywords[0]) return true;
7777
const data = ` ${item.name} ${item.platforms} ${item.technologies} `.toLowerCase();
7878
for (let i = 0; i !== this.keywords.length; i += 1) {

components/ChallengeStatus/ChallengeStatus.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ class ChallengeStatus extends Component {
180180
const { challenge } = this.props;
181181
const { DS_CHALLENGE_URL, CHALLENGE_URL } = this.state;
182182
const { id, track } = challenge;
183-
const challengeURL = track.toLowerCase() === 'data' ? DS_CHALLENGE_URL : CHALLENGE_URL;
184183

184+
const challengeURL = track === 'DATA_SCIENCE' ? DS_CHALLENGE_URL : CHALLENGE_URL;
185185
let winners = challenge.winners && challenge.winners.filter(winner => winner.type === 'final')
186186
.map(winner => ({
187187
handle: winner.handle,
@@ -308,7 +308,7 @@ class ChallengeStatus extends Component {
308308
</span>
309309
<ProgressBarTooltip challenge={challenge} config={config}>
310310
{
311-
challenge.status === 'ACTIVE' ?
311+
challenge.status === 'ACTIVE' && challenge.currentPhases.length > 0 ?
312312
<div>
313313
<ChallengeProgressBar
314314
color="green"

0 commit comments

Comments
 (0)