diff --git a/app/profile/profile.spec.js b/app/profile/profile.spec.js index 2176dfdca..ffecfcd20 100644 --- a/app/profile/profile.spec.js +++ b/app/profile/profile.spec.js @@ -18,7 +18,7 @@ describe('Profile Controller', function() { var profileService = { getUserStats: function() { - return $q.when({result: {content: mockStats}}) + return $q.when({result: {content: [mockStats]}}) }, getUserSkills: function() { return $q.when({result: {content: mockSkills}}) diff --git a/app/services/profile.service.js b/app/services/profile.service.js index b28dcd967..34bdd02cb 100644 --- a/app/services/profile.service.js +++ b/app/services/profile.service.js @@ -80,11 +80,15 @@ import _ from 'lodash' } function getUserStats(username) { - return restangular.one('members', username).one('stats').get().then(function(data) { - if (data && !data.DEVELOP) data.DEVELOP = {challenges: 0, wins: 0, subTracks: []} - if (data && !data.DESIGN) data.DESIGN = {challenges: 0, wins: 0, subTracks: []} - if (data && !data.DATA_SCIENCE) data.DATA_SCIENCE = {challenges: 0, wins: 0, SRM: {}, MARATHON_MATCH: {}} - return data + return restangular.one('members', username).one('stats').get({ groupIds: CONSTANTS.DEFAULT_GROUP_ID }).then(function(data) { + var stats = {} + if (Array.isArray(data) && data.length) { + stats = data[0] + if (!stats.DEVELOP) stats.DEVELOP = {challenges: 0, wins: 0, subTracks: []} + if (!stats.DESIGN) stats.DESIGN = {challenges: 0, wins: 0, subTracks: []} + if (!stats.DATA_SCIENCE) stats.DATA_SCIENCE = {challenges: 0, wins: 0, SRM: {}, MARATHON_MATCH: {}} + } + return stats }) } diff --git a/app/services/profile.service.spec.js b/app/services/profile.service.spec.js index 1b12b7d4a..980c49512 100644 --- a/app/services/profile.service.spec.js +++ b/app/services/profile.service.spec.js @@ -20,8 +20,8 @@ describe('Profile Service', function() { .respond(200, {result: {content: mockProfile}}) // mock stats $httpBackend - .when('GET', apiUrl + '/members/rakesh/stats/') - .respond(200, {result: {content: mockStats}}) + .when('GET', apiUrl + '/members/rakesh/stats/?groupIds=' + CONSTANTS.DEFAULT_GROUP_ID) + .respond(200, {result: {content: [mockStats]}}) }) diff --git a/app/topcoder.constants.js b/app/topcoder.constants.js index b768faf17..333264257 100644 --- a/app/topcoder.constants.js +++ b/app/topcoder.constants.js @@ -47,5 +47,6 @@ angular.module('CONSTANTS', []).constant('CONSTANTS', { 'STATUS_COMPLETED_WITHOUT_WIN' : 'Completed Without Win', 'CHALLENGES_LOADING_CHUNK' : 36, 'INFINITE_SCROLL_OFFSET' : '400', // footer is 300px and challenge tile is 400px - 'VIDEO_DEFAULT_HEIGHT': 360 + 'VIDEO_DEFAULT_HEIGHT': 360, + 'DEFAULT_GROUP_ID': 10 })