Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b477ee4

Browse files
committedNov 16, 2015
Merge pull request #553 from appirio-tech/feature/SUP-2575
Fixed track and subtrack ordering
2 parents 048477e + 2bec27b commit b477ee4

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed
 

‎app/profile/about/about.jade

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
empty-state-placeholder(state-name="profile-topcoder-activity", show="!profileVm.showTCActivity", theme="offwhite")
4848

4949
.track(
50-
ng-repeat="track in profileVm.profile.tracks",
50+
ng-repeat="track in profileVm.tracks",
5151
ng-if="profileVm.categories[track].showTrack",
5252
id="{{track}}_TRACK"
5353
)
@@ -60,7 +60,7 @@
6060
span {{track | track | uppercase}} ACTIVITY
6161

6262
a.subtrack(
63-
ng-repeat="subtrack in profileVm.categories[track] | orderBy:'mostRecentEventDate':true",
63+
ng-repeat="subtrack in profileVm.categories[track]",
6464
ui-sref="profile.subtrack({track: subtrack.track, subTrack: subtrack.subTrack})",
6565
class="{{$index == 0 && 'first'}}"
6666
ng-if="subtrack.showStats"

‎app/profile/profile.controller.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
if (stats) {
4141
vm.stats = stats;
4242
vm.profile.tracks = vm.profile.tracks || [];
43+
vm.tracks = ProfileService.getTracks(stats) || vm.profile.tracks;
4344
if (stats.COPILOT && stats.COPILOT.contests && vm.profile.tracks.indexOf('COPILOT') == -1) {
4445
vm.profile.tracks.push('COPILOT');
4546
}

‎app/services/profile.service.js

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
getHistoryStats: getHistoryStats,
2626
// auxiliary functions for profile
2727
getRanks: getRanks,
28+
sortByDate: sortByDate,
2829
getChallengeTypeStats: getChallengeTypeStats,
2930
getTracks: getTracks,
3031
getSubTracks: getSubTracks,
@@ -149,7 +150,7 @@
149150
'rank': marathonStats.rank.rank,
150151
'rating': marathonStats.rank.rating,
151152
'mostRecentEventDate': new Date(marathonStats.rank.mostRecentEventDate),
152-
'mostRecentSubmissionDate': new Date(marathonStats.mostRecentSubmission)
153+
'mostRecentSubmission': new Date(marathonStats.mostRecentSubmission)
153154
});
154155
}
155156
if (stats.COPILOT) {
@@ -159,6 +160,11 @@
159160
stats.COPILOT.track = 'COPILOT';
160161
stats.COPILOT.subTrack = 'COPILOT';
161162
}
163+
164+
sortByDate(dev);
165+
sortByDate(design);
166+
sortByDate(dataScience);
167+
162168
var compiledStats = {
163169
'DEVELOP': removeRanklessNoSubmissions(dev),
164170
'DESIGN': removeRanklessNoSubmissions(design),
@@ -175,6 +181,18 @@
175181
return compiledStats;
176182
}
177183

184+
185+
function sortByDate(arr) {
186+
arr.sort(function(a, b) {
187+
if (!(a.mostRecentSubmission || a.mostRecentEventDate)) return -1;
188+
if (!(b.mostRecentSubmission || b.mostRecentEventDate)) return 1;
189+
a = new Date(a.mostRecentSubmission || a.mostRecentEventDate);
190+
b = new Date(b.mostRecentSubmission || b.mostRecentEventDate);
191+
return a > b ? -1 : a < b ? 1 : 0;
192+
});
193+
}
194+
195+
178196
function getChallengeTypeStats(stats, track, type) {
179197
track = track.toUpperCase().replace(/ /g, '_');
180198
track = track.replace(/-/g, '');
@@ -242,20 +260,31 @@
242260
{
243261
'name': 'DEVELOP',
244262
'challenges': stats.DEVELOP.challenges,
263+
'mostRecentEventDate': new Date(stats.DEVELOP.mostRecentEventDate),
264+
'mostRecentSubmission': new Date(stats.DEVELOP.mostRecentSubmision)
245265
},
246266
{
247267
'name': 'DESIGN',
248268
'challenges': stats.DESIGN.challenges,
269+
'mostRecentEventDate': new Date(stats.DESIGN.mostRecentEventDate),
270+
'mostRecentSubmission': new Date(stats.DESIGN.mostRecentSubmision)
249271
},
250272
{
251273
'name': 'DATA_SCIENCE',
252274
'challenges': stats.DATA_SCIENCE.challenges,
275+
'mostRecentEventDate': new Date(stats.DATA_SCIENCE.mostRecentEventDate),
276+
'mostRecentSubmission': new Date(stats.DATA_SCIENCE.mostRecentSubmision)
253277
}
254278
].filter(function(track) {
255279
return track.challenges > 0;
256-
}).map(function(track) {
280+
});
281+
sortByDate(tracks);
282+
tracks = tracks.map(function(track) {
257283
return track.name;
258284
});
285+
if (stats.COPILOT) {
286+
tracks = ['COPILOT'].concat(tracks);
287+
}
259288
return tracks;
260289
}
261290

0 commit comments

Comments
 (0)
This repository has been archived.