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

Fixed p0 #510

Merged
merged 4 commits into from
Oct 30, 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
1 change: 0 additions & 1 deletion app/my-dashboard/my-challenges/my-challenges.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
ChallengeService.getUserMarathonMatches(handle, marathonMatchParams),
ChallengeService.getUserChallenges(handle, challengeParams)
]).then(function(challenges){
console.log('challenges: ', challenges);
var marathonMatches = challenges[0];
var devDesignChallenges = challenges[1];

Expand Down
3 changes: 3 additions & 0 deletions app/my-dashboard/subtrack-stats/subtrack-stats.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
var subtrackRanks = UserStatsService.compileSubtracks(trackRanks);

UserStatsService.processStats(subtrackRanks);
// filter stats based on processing done above
// filtering is a separate step to allow multiple pre-processings and filter out in single call
subtrackRanks = UserStatsService.filterStats(subtrackRanks);
// sort subtrack ranks
subtrackRanks = $filter('orderBy')(subtrackRanks, 'mostRecentEventDate', true);

Expand Down
5 changes: 3 additions & 2 deletions app/profile/about/about.jade
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

.track(
ng-repeat="track in profileVm.profile.tracks",
ng-if="profileVm.categories[track].length > 0",
ng-if="profileVm.categories[track].showTrack",
id="{{track}}_TRACK"
)

Expand All @@ -63,6 +63,7 @@
ng-repeat="subtrack in profileVm.categories[track] | orderBy:'mostRecentEventDate':true",
ui-sref="profile.subtrack({track: subtrack.track, subTrack: subtrack.subTrack})",
class="{{$index == 0 && 'first'}}"
ng-if="subtrack.showStats"
)
.name {{subtrack.subTrack | track}}

Expand All @@ -77,7 +78,7 @@

.tag Ranking

.ranking(ng-if="subtrack.wins !== null && subtrack.rank === null && !subtrack.rating")
.ranking(ng-if="subtrack.statType === 'Wins'")
.number(style="color: #21B2F1") {{subtrack.wins}}

.tag Wins
Expand Down
17 changes: 15 additions & 2 deletions app/profile/profile.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
angular.module('tc.profile').controller('ProfileCtrl', ProfileCtrl);

ProfileCtrl.$inject = ['CONSTANTS', '$log', '$q',
'TcAuthService', 'UserService', 'ProfileService', 'ChallengeService', 'ExternalAccountService',
'TcAuthService', 'UserService', 'UserStatsService', 'ProfileService', 'ChallengeService', 'ExternalAccountService',
'userHandle', 'profile', 'ngDialog', '$anchorScroll'
];

function ProfileCtrl(CONSTANTS, $log, $q, TcAuthService, UserService, ProfileService, ChallengeService, ExternalAccountService, userHandle, profile, ngDialog, $anchorScroll) {
function ProfileCtrl(CONSTANTS, $log, $q, TcAuthService, UserService, UserStatsService, ProfileService, ChallengeService, ExternalAccountService, userHandle, profile, ngDialog, $anchorScroll) {
var vm = this;
// set profile to the object that was resolved
vm.profile = profile;
Expand Down Expand Up @@ -45,6 +45,19 @@
vm.numProjects = vm.stats.challenges;
vm.numWins = vm.stats.wins;
vm.categories = ProfileService.getRanks(vm.stats);
for(var trackName in vm.categories) {
// trackStats is an array of subtrack rankings along with track stats properties (e.g showTrack)
var trackStats = vm.categories[trackName];
trackStats.showTrack = false;
if (trackStats && trackStats.length > 0) {
trackStats.forEach(function(subTrackRank) {
UserStatsService.processStatRank(subTrackRank);
if (subTrackRank.showStats) {
trackStats.showTrack = true;
}
});
}
}
} else {
vm.stats = false;
// vm.profile.tracks = [];
Expand Down
1 change: 1 addition & 0 deletions app/services/profile.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
'rank': false,
'challenges': subTrack.challenges,
'wins': subTrack.wins,
'submissions': (subTrack.submissions) || 0,
'mostRecentEventDate': new Date(subTrack.mostRecentEventDate)
};
});
Expand Down
53 changes: 39 additions & 14 deletions app/services/userStats.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
var service = {
getIterableStats: getIterableStats,
processStats: processStats,
compileSubtracks: compileSubtracks
compileSubtracks: compileSubtracks,
filterStats: filterStats,
processStatRank: processStatRank
};

var percentageFunc = function(n) { return $filter('percentage')(n);};
Expand Down Expand Up @@ -111,27 +113,50 @@
}, []);
}

function processStats(ranks) {
angular.forEach(ranks, function(rank) {
if (rank.track === 'DESIGN') {
function processStatRank(rank) {
rank.showStats = true;
if (rank.track === 'DESIGN') {
rank.stat = rank.wins;
rank.statType = 'Wins';
// for non rated tracks, use submissions to filter out empty values
if(!rank.submissions) {
rank.showStats = false;
}
} else if (rank.track === 'COPILOT') {
rank.stat = rank.activeContests;
rank.statType = 'Challenges';
} else if (rank.track === 'DEVELOP') {
if (['CODE', 'FIRST_2_FINISH'].indexOf(rank.subTrack) != -1) {
rank.stat = rank.wins;
rank.statType = 'Wins';
} else if (rank.track === 'COPILOT') {
rank.stat = rank.activeContests;
rank.statType = 'Challenges';
} else if (rank.track === 'DEVELOP') {
if (['CODE', 'FIRST_2_FINISH'].indexOf(rank.subTrack) != -1) {
rank.stat = rank.wins;
rank.statType = 'Wins';
} else {
rank.stat = rank.rating;
rank.statType = 'Rating';
// for non rated tracks, use submissions to filter out empty values
if(!rank.submissions) {
rank.showStats = false;
}
} else {
rank.stat = rank.rating;
rank.statType = 'Rating';
}
} else {
rank.stat = rank.rating;
rank.statType = 'Rating';
}
}

function processStats(ranks) {
angular.forEach(ranks, function(rank) {
processStatRank(rank);
});
}

function filterStats(ranks) {
var filtered = [];
angular.forEach(ranks, function(rank) {
if (rank.showStats) {
filtered.push(rank);
}
});
return filtered;
}


Expand Down