Skip to content
Merged
Changes from all 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
20 changes: 15 additions & 5 deletions src/services/challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,16 @@ export const ORDER_BY = {
*/
export function normalizeChallenge(challenge, username) {
const phases = challenge.allPhases || challenge.phases || [];
let registrationOpen = phases.filter(d => d.name === 'Registration')[0];
if (registrationOpen && registrationOpen.isOpen) {
registrationOpen = 'Yes';
} else {
registrationOpen = 'No';
const registration = phases.filter(d => d.name === 'Registration')[0];
let registrationOpen = 'No';
let registrationStartDate;
let registrationEndDate;
if (registration) {
registrationStartDate = registration.actualStartDate || registration.scheduledStartDate;
if (registration.isOpen) {
registrationOpen = 'Yes';
}
registrationEndDate = registration.actualEndDate || registration.scheduledEndDate;
}
const groups = {};
if (challenge.groups) {
Expand All @@ -56,11 +61,16 @@ export function normalizeChallenge(challenge, username) {
if (submissionEndTimestamp) {
submissionEndTimestamp = submissionEndTimestamp.scheduledEndDate;
}
const prizes = (challenge.prizeSets[0] && challenge.prizeSets[0].prizes) || [];
_.defaults(challenge, {
communities: new Set([COMPETITION_TRACKS[challenge.legacy.track]]),
groups,
registrationOpen,
submissionEndTimestamp,
registrationStartDate,
registrationEndDate,
totalPrize: prizes.reduce((acc, prize) => acc + prize.value, 0),
submissionEndDate: submissionEndTimestamp,
users: username ? { [username]: true } : {},
});
}
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy