Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Fixed showing top placements #587

Merged
merged 1 commit into from
Dec 1, 2015
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
6 changes: 4 additions & 2 deletions app/services/challenge.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
// TODO placement logic for challenges can be moved to their corresponding user place directive
// process placement for challenges having winningPlacements array in response
if (Array.isArray(challenge.userDetails.winningPlacements)) {
challenge.highestPlacement = _.max(challenge.userDetails.winningPlacements);
challenge.highestPlacement = _.min(challenge.userDetails.winningPlacements);
challenge.wonFirst = challenge.highestPlacement == 1;
if (challenge.highestPlacement === 0) {
challenge.highestPlacement = null;
Expand All @@ -189,7 +189,9 @@
if (challenge.track == 'DESIGN' && challenge.userDetails.submissions && challenge.userDetails.submissions.length > 0) {
challenge.thumbnailId = challenge.userDetails.submissions[0].id;

challenge.highestPlacement = _.max(challenge.userDetails.submissions, 'placement').placement;
challenge.highestPlacement = _.min(challenge.userDetails.submissions.filter(function(submission) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are not filtering anything here, can we use map instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're filtering the ones that have falsey values for the 'placement' property.

return submission.placement;
}), 'placement').placement;

if (challenge.highestPlacement == 1) {
challenge.wonFirst = true;
Expand Down