|
25 | 25 | getHistoryStats: getHistoryStats,
|
26 | 26 | // auxiliary functions for profile
|
27 | 27 | getRanks: getRanks,
|
| 28 | + sortByDate: sortByDate, |
28 | 29 | getChallengeTypeStats: getChallengeTypeStats,
|
29 | 30 | getTracks: getTracks,
|
30 | 31 | getSubTracks: getSubTracks,
|
|
149 | 150 | 'rank': marathonStats.rank.rank,
|
150 | 151 | 'rating': marathonStats.rank.rating,
|
151 | 152 | 'mostRecentEventDate': new Date(marathonStats.rank.mostRecentEventDate),
|
152 |
| - 'mostRecentSubmissionDate': new Date(marathonStats.mostRecentSubmission) |
| 153 | + 'mostRecentSubmission': new Date(marathonStats.mostRecentSubmission) |
153 | 154 | });
|
154 | 155 | }
|
155 | 156 | if (stats.COPILOT) {
|
|
159 | 160 | stats.COPILOT.track = 'COPILOT';
|
160 | 161 | stats.COPILOT.subTrack = 'COPILOT';
|
161 | 162 | }
|
| 163 | + |
| 164 | + sortByDate(dev); |
| 165 | + sortByDate(design); |
| 166 | + sortByDate(dataScience); |
| 167 | + |
162 | 168 | var compiledStats = {
|
163 | 169 | 'DEVELOP': removeRanklessNoSubmissions(dev),
|
164 | 170 | 'DESIGN': removeRanklessNoSubmissions(design),
|
|
175 | 181 | return compiledStats;
|
176 | 182 | }
|
177 | 183 |
|
| 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 | + |
178 | 196 | function getChallengeTypeStats(stats, track, type) {
|
179 | 197 | track = track.toUpperCase().replace(/ /g, '_');
|
180 | 198 | track = track.replace(/-/g, '');
|
|
242 | 260 | {
|
243 | 261 | 'name': 'DEVELOP',
|
244 | 262 | 'challenges': stats.DEVELOP.challenges,
|
| 263 | + 'mostRecentEventDate': new Date(stats.DEVELOP.mostRecentEventDate), |
| 264 | + 'mostRecentSubmission': new Date(stats.DEVELOP.mostRecentSubmision) |
245 | 265 | },
|
246 | 266 | {
|
247 | 267 | 'name': 'DESIGN',
|
248 | 268 | 'challenges': stats.DESIGN.challenges,
|
| 269 | + 'mostRecentEventDate': new Date(stats.DESIGN.mostRecentEventDate), |
| 270 | + 'mostRecentSubmission': new Date(stats.DESIGN.mostRecentSubmision) |
249 | 271 | },
|
250 | 272 | {
|
251 | 273 | 'name': 'DATA_SCIENCE',
|
252 | 274 | 'challenges': stats.DATA_SCIENCE.challenges,
|
| 275 | + 'mostRecentEventDate': new Date(stats.DATA_SCIENCE.mostRecentEventDate), |
| 276 | + 'mostRecentSubmission': new Date(stats.DATA_SCIENCE.mostRecentSubmision) |
253 | 277 | }
|
254 | 278 | ].filter(function(track) {
|
255 | 279 | return track.challenges > 0;
|
256 |
| - }).map(function(track) { |
| 280 | + }); |
| 281 | + sortByDate(tracks); |
| 282 | + tracks = tracks.map(function(track) { |
257 | 283 | return track.name;
|
258 | 284 | });
|
| 285 | + if (stats.COPILOT) { |
| 286 | + tracks = ['COPILOT'].concat(tracks); |
| 287 | + } |
259 | 288 | return tracks;
|
260 | 289 | }
|
261 | 290 |
|
|
0 commit comments