|
6 | 6 | HeaderDashboardController.$inject = [
|
7 | 7 | '$stateParams',
|
8 | 8 | 'NotificationService',
|
9 |
| - 'UserService', |
10 | 9 | 'ProfileService',
|
11 | 10 | 'CONSTANTS',
|
12 |
| - 'userIdentity' |
| 11 | + 'userIdentity', |
| 12 | + '$q' |
13 | 13 | ];
|
14 | 14 |
|
15 |
| - function HeaderDashboardController($stateParams, NotificationService, UserService, ProfileService, CONSTANTS, userIdentity) { |
| 15 | + function HeaderDashboardController($stateParams, NotificationService, ProfileService, CONSTANTS, userIdentity, $q) { |
16 | 16 | var vm = this;
|
17 | 17 | vm.domain = CONSTANTS.domain;
|
18 | 18 | vm.defaultPhotoUrl = CONSTANTS.ASSET_PREFIX + "images/avatarPlaceholder.png";
|
|
30 | 30 | function activate() {
|
31 | 31 | var handle = userIdentity.handle;
|
32 | 32 |
|
33 |
| - ProfileService.getUserProfile(handle) |
34 |
| - .then(function(profile) { |
35 |
| - vm.profile = profile; |
36 |
| - }); |
| 33 | + $q.all([ |
| 34 | + ProfileService.getUserStats(handle), |
| 35 | + ProfileService.getUserFinancials(handle) |
| 36 | + ]).then(function(data) { |
| 37 | + var stats = data[0]; |
| 38 | + var financials = data[1]; |
| 39 | + |
| 40 | + vm.moneyEarned = _.sum(_.pluck(financials, 'amount')); |
37 | 41 |
|
38 |
| - ProfileService.getUserStats(handle) |
39 |
| - .then(function(stats) { |
40 | 42 | if (stats.COPILOT != null) {
|
41 | 43 | vm.numCopilotActiveContests = stats.COPILOT.activeContests;
|
42 | 44 | } else {
|
43 | 45 | vm.numCopilotActiveContests = 0;
|
44 | 46 | }
|
45 | 47 |
|
46 |
| - vm.rankStats = ProfileService.getRanks(stats); |
47 |
| - |
48 |
| - if (vm.rankStats.length === 0) { |
49 |
| - vm.hasRatings = false; |
50 |
| - } |
51 |
| - |
52 | 48 | vm.loading = false;
|
53 | 49 | })
|
54 | 50 | .catch(function(err) {
|
55 | 51 | vm.hasRatings = false;
|
56 | 52 | vm.loading = false;
|
57 |
| - // todo handle error |
58 |
| - }) |
59 |
| - |
60 |
| - ProfileService.getUserFinancials(handle) |
61 |
| - .then(function(financials) { |
62 |
| - vm.moneyEarned = _.sum(_.pluck(financials, 'amount')); |
63 | 53 | });
|
64 | 54 | }
|
65 | 55 | }
|
|
0 commit comments