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

Commit 7645fea

Browse files
Merge pull request #1318 from appirio-tech/feature-stats-accomodate
output from challenge 30115866
2 parents c06394e + 14189de commit 7645fea

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

app/profile/profile.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('Profile Controller', function() {
1818

1919
var profileService = {
2020
getUserStats: function() {
21-
return $q.when({result: {content: mockStats}})
21+
return $q.when({result: {content: [mockStats]}})
2222
},
2323
getUserSkills: function() {
2424
return $q.when({result: {content: mockSkills}})

app/services/profile.service.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,15 @@ import _ from 'lodash'
8080
}
8181

8282
function getUserStats(username) {
83-
return restangular.one('members', username).one('stats').get().then(function(data) {
84-
if (data && !data.DEVELOP) data.DEVELOP = {challenges: 0, wins: 0, subTracks: []}
85-
if (data && !data.DESIGN) data.DESIGN = {challenges: 0, wins: 0, subTracks: []}
86-
if (data && !data.DATA_SCIENCE) data.DATA_SCIENCE = {challenges: 0, wins: 0, SRM: {}, MARATHON_MATCH: {}}
87-
return data
83+
return restangular.one('members', username).one('stats').get({ groupIds: CONSTANTS.DEFAULT_GROUP_ID }).then(function(data) {
84+
var stats = {}
85+
if (Array.isArray(data) && data.length) {
86+
stats = data[0]
87+
if (!stats.DEVELOP) stats.DEVELOP = {challenges: 0, wins: 0, subTracks: []}
88+
if (!stats.DESIGN) stats.DESIGN = {challenges: 0, wins: 0, subTracks: []}
89+
if (!stats.DATA_SCIENCE) stats.DATA_SCIENCE = {challenges: 0, wins: 0, SRM: {}, MARATHON_MATCH: {}}
90+
}
91+
return stats
8892
})
8993
}
9094

app/services/profile.service.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ describe('Profile Service', function() {
2020
.respond(200, {result: {content: mockProfile}})
2121
// mock stats
2222
$httpBackend
23-
.when('GET', apiUrl + '/members/rakesh/stats/')
24-
.respond(200, {result: {content: mockStats}})
23+
.when('GET', apiUrl + '/members/rakesh/stats/?groupIds=' + CONSTANTS.DEFAULT_GROUP_ID)
24+
.respond(200, {result: {content: [mockStats]}})
2525

2626
})
2727

app/topcoder.constants.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,6 @@ angular.module('CONSTANTS', []).constant('CONSTANTS', {
4747
'STATUS_COMPLETED_WITHOUT_WIN' : 'Completed Without Win',
4848
'CHALLENGES_LOADING_CHUNK' : 36,
4949
'INFINITE_SCROLL_OFFSET' : '400', // footer is 300px and challenge tile is 400px
50-
'VIDEO_DEFAULT_HEIGHT': 360
50+
'VIDEO_DEFAULT_HEIGHT': 360,
51+
'DEFAULT_GROUP_ID': 10
5152
})

0 commit comments

Comments
 (0)