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

Commit f019d70

Browse files
author
Parth Shah
committed
attempting to clean up community app, moving data to a service
1 parent 72ea978 commit f019d70

File tree

9 files changed

+237
-263
lines changed

9 files changed

+237
-263
lines changed

app/community/community.routes.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@
2828
data: {
2929
authRequired: false,
3030
title: 'Community Members'
31-
},
32-
resolve: {
33-
membersData: function($http) {
34-
// TODO this needs to move to a service
35-
return $http.get('community/mock-data/members.json', {skipAuthorization: true});
36-
}
3731
}
3832
},
3933

@@ -45,14 +39,8 @@
4539
controllerAs: 'ctrl',
4640
data: {
4741
title: 'Community Statistics'
48-
},
49-
resolve: {
50-
statData: function($http) {
51-
// TODO this needs to move to a service
52-
return $http.get('community/mock-data/statistics.json', {skipAuthorization: true});
53-
}
5442
}
55-
},
43+
}
5644
};
5745

5846
angular.forEach(states, function(state, name) {

app/community/members.controller.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@
33

44
angular.module('tc.community').controller('MembersController', MembersController);
55

6-
MembersController.$inject = ['membersData', '$http', 'CONSTANTS'];
6+
MembersController.$inject = ['CommunityDataService', 'CONSTANTS'];
77

8-
function MembersController(membersData, $http, CONSTANTS) {
8+
function MembersController(CommunityDataService, CONSTANTS) {
9+
var ctrl = this;
10+
ctrl.notSearch = true;
11+
ctrl.showing = 'list';
12+
ctrl.domain = CONSTANTS.domain;
13+
ctrl.currentMonth = 'October 2015';
14+
ctrl.memberLeaderboard = [];
15+
ctrl.copilots = [];
16+
CommunityDataService.getMembersData()
17+
.then(function(data) {
18+
ctrl.memberLeaderboard = data.memberLeaderboard;
19+
ctrl.copilots = data.copilots;
20+
});
921

10-
this.notSearch = true;
11-
this.showing = 'list';
12-
this.domain = CONSTANTS.domain;
13-
this.currentMonth = 'October 2015';
14-
this.memberLeaderboard = membersData.data.memberLeaderboard;
15-
this.copilots = membersData.data.copilots;
16-
this.search = function() {
17-
if (this.keywords) {
18-
window.location.replace('/search?s=' + this.keywords + '&scope=member');
19-
20-
//$http.get('community/mock-data/search-result.json')
21-
// .success(function(data) {
22-
// this.searchResult = data.result;
23-
// this.notSearch = false;
24-
// }.bind(this));
22+
ctrl.search = function() {
23+
if (ctrl.keywords) {
24+
window.location.replace('/search?s=' + ctrl.keywords + '&scope=member');
2525
} else {
26-
this.notSearch = true;
26+
ctrl.notSearch = true;
2727
}
2828
};
2929
}

app/community/mock-data/avatar.png

-831 Bytes
Binary file not shown.

app/community/mock-data/members.json

Lines changed: 0 additions & 46 deletions
This file was deleted.

app/community/mock-data/search-result.json

Lines changed: 0 additions & 51 deletions
This file was deleted.

app/community/mock-data/statistics.json

Lines changed: 0 additions & 125 deletions
This file was deleted.
Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
1-
(function () {
1+
(function() {
22
'use strict';
33

44
angular.module('tc.community').controller('StatisticsController', StatisticsController);
55

6-
StatisticsController.$inject = ['statData', 'StatisticsService', 'CONSTANTS'];
6+
StatisticsController.$inject = ['CommunityDataService', 'StatisticsService', 'CONSTANTS'];
77

8-
function StatisticsController(statData, StatisticsService, CONSTANTS) {
8+
function StatisticsController(CommunityDataService, StatisticsService, CONSTANTS) {
99
var statsData = this;
1010
statsData.domain = CONSTANTS.domain;
11-
statsData.SRMWinners = statData.data.SRMWinners;
12-
statsData.MarathonWinner = statData.data.MarathonWinner;
11+
statsData.SRMWinners = [];
12+
statsData.MarathonWinner = [];
1313
statsData.TopPerformers = [];
1414

15-
StatisticsService.getDesignTop(10).then(function (data) {
15+
CommunityDataService.getStatisticsData()
16+
.then(function(data) {
17+
statsData.SRMWinners = data.SRMWinners;
18+
statsData.MarathonWinner = data.MarathonWinner;
19+
});
20+
21+
StatisticsService.getDesignTop(10).then(function(data) {
1622
statsData.TopPerformers.push({
1723
"contestType": "Design",
1824
"class": "design",
1925
"dataType": "Wins",
2026
"performers": data.plain().data
21-
});
27+
});
2228
});
2329

24-
StatisticsService.getDevTop(10).then(function (data) {
30+
StatisticsService.getDevTop(10).then(function(data) {
2531
statsData.TopPerformers.push({
2632
"contestType": "Development",
2733
"class": "develop",
@@ -30,14 +36,13 @@
3036
});
3137
});
3238

33-
StatisticsService.getDataTop(10).then(function (data) {
39+
StatisticsService.getDataTop(10).then(function(data) {
3440
statsData.TopPerformers.push({
3541
"contestType": "Competitive Programming",
3642
"class": "data-science",
3743
"dataType": "Rating",
3844
"performers": data.plain().data
3945
});
4046
});
41-
console.log(statsData.TopPerformers);
4247
}
4348
})();

app/index.jade

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ html
263263
script(src="services/authtoken.service.js")
264264
script(src="services/blog.service.js")
265265
script(src="services/challenge.service.js")
266+
script(src="services/communityData.service.js")
266267
script(src="services/externalAccounts.service.js")
267268
script(src="services/helpers.service.js")
268269
script(src="services/image.service.js")

0 commit comments

Comments
 (0)