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

Fixed track and subtrack ordering #553

Merged
merged 1 commit into from
Nov 16, 2015
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions app/profile/about/about.jade
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
empty-state-placeholder(state-name="profile-topcoder-activity", show="!profileVm.showTCActivity", theme="offwhite")

.track(
ng-repeat="track in profileVm.profile.tracks",
ng-repeat="track in profileVm.tracks",
ng-if="profileVm.categories[track].showTrack",
id="{{track}}_TRACK"
)
Expand All @@ -60,7 +60,7 @@
span {{track | track | uppercase}} ACTIVITY

a.subtrack(
ng-repeat="subtrack in profileVm.categories[track] | orderBy:'mostRecentEventDate':true",
ng-repeat="subtrack in profileVm.categories[track]",
ui-sref="profile.subtrack({track: subtrack.track, subTrack: subtrack.subTrack})",
class="{{$index == 0 && 'first'}}"
ng-if="subtrack.showStats"
Expand Down
1 change: 1 addition & 0 deletions app/profile/profile.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
if (stats) {
vm.stats = stats;
vm.profile.tracks = vm.profile.tracks || [];
vm.tracks = ProfileService.getTracks(stats) || vm.profile.tracks;
if (stats.COPILOT && stats.COPILOT.contests && vm.profile.tracks.indexOf('COPILOT') == -1) {
vm.profile.tracks.push('COPILOT');
}
Expand Down
33 changes: 31 additions & 2 deletions app/services/profile.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
getHistoryStats: getHistoryStats,
// auxiliary functions for profile
getRanks: getRanks,
sortByDate: sortByDate,
getChallengeTypeStats: getChallengeTypeStats,
getTracks: getTracks,
getSubTracks: getSubTracks,
Expand Down Expand Up @@ -149,7 +150,7 @@
'rank': marathonStats.rank.rank,
'rating': marathonStats.rank.rating,
'mostRecentEventDate': new Date(marathonStats.rank.mostRecentEventDate),
'mostRecentSubmissionDate': new Date(marathonStats.mostRecentSubmission)
'mostRecentSubmission': new Date(marathonStats.mostRecentSubmission)
});
}
if (stats.COPILOT) {
Expand All @@ -159,6 +160,11 @@
stats.COPILOT.track = 'COPILOT';
stats.COPILOT.subTrack = 'COPILOT';
}

sortByDate(dev);
sortByDate(design);
sortByDate(dataScience);

var compiledStats = {
'DEVELOP': removeRanklessNoSubmissions(dev),
'DESIGN': removeRanklessNoSubmissions(design),
Expand All @@ -175,6 +181,18 @@
return compiledStats;
}


function sortByDate(arr) {
arr.sort(function(a, b) {
if (!(a.mostRecentSubmission || a.mostRecentEventDate)) return -1;
if (!(b.mostRecentSubmission || b.mostRecentEventDate)) return 1;
a = new Date(a.mostRecentSubmission || a.mostRecentEventDate);
b = new Date(b.mostRecentSubmission || b.mostRecentEventDate);
return a > b ? -1 : a < b ? 1 : 0;
});
}


function getChallengeTypeStats(stats, track, type) {
track = track.toUpperCase().replace(/ /g, '_');
track = track.replace(/-/g, '');
Expand Down Expand Up @@ -242,20 +260,31 @@
{
'name': 'DEVELOP',
'challenges': stats.DEVELOP.challenges,
'mostRecentEventDate': new Date(stats.DEVELOP.mostRecentEventDate),
'mostRecentSubmission': new Date(stats.DEVELOP.mostRecentSubmision)
},
{
'name': 'DESIGN',
'challenges': stats.DESIGN.challenges,
'mostRecentEventDate': new Date(stats.DESIGN.mostRecentEventDate),
'mostRecentSubmission': new Date(stats.DESIGN.mostRecentSubmision)
},
{
'name': 'DATA_SCIENCE',
'challenges': stats.DATA_SCIENCE.challenges,
'mostRecentEventDate': new Date(stats.DATA_SCIENCE.mostRecentEventDate),
'mostRecentSubmission': new Date(stats.DATA_SCIENCE.mostRecentSubmision)
}
].filter(function(track) {
return track.challenges > 0;
}).map(function(track) {
});
sortByDate(tracks);
tracks = tracks.map(function(track) {
return track.name;
});
if (stats.COPILOT) {
tracks = ['COPILOT'].concat(tracks);
}
return tracks;
}

Expand Down