diff --git a/models/User.py b/models/User.py index b413008..88e6222 100644 --- a/models/User.py +++ b/models/User.py @@ -3,6 +3,7 @@ import json __author__ = 'Aran' from google.appengine.ext import db + class User(db.Model): username = db.StringProperty(required=True) name = db.StringProperty(required=False) @@ -26,6 +27,64 @@ class User(db.Model): 'campuses_id_list': self.campuses_id_list, 'courses_id_list': self.courses_id_list, 'projects_id_list': self.projects_id_list, - 'id' : self.key().id() + 'id' : self.key().id(), + 'stats': get_stats(self) } return json.dumps(data) + +def get_stats(user): + from models.Project import Project + from models.Message import Message + labels = ['Commits', 'Open Issues Assigned', 'Messages', 'Unfinished Tasks'] + data = [0, 0, 0, 0] + for pid in user.projects_id_list: + project = Project.get_by_id(int(pid)) + info = json.loads(project.info) + stats = info["stats"]['micro'] + p_data = stats['data'] + p_series = stats['series'] + user_index = p_series.index(user.username) + #adding commits + data[0] = data[0] + p_data[user_index][0] + #adding open issues + data[1] = data[1] + p_data[user_index][1] + messages = Message.all().filter('master_id =', user.key().id()) + for m in messages.run(): + data[2] = data[2] + 1 + + #need to do tasks + #### + + data = [data] + return {'data': data, 'labels': labels} + +""" +info: Object +commits: Array[30] +info: Object +issues: Array[7] +stats: Object +macro: Object +micro: Object +data: Array[4] +0: Array[2] +0: 13 +1: 1 +length: 2 +__proto__: Array[0] +1: Array[2] +2: Array[2] +3: Array[2] +length: 4 +__proto__: Array[0] +labels: Array[2] +0: "Commits" +1: "Open Issues" +length: 2 +__proto__: Array[0] +series: Array[4] +0: "etyemy" +1: "devMatan" +2: "aranzaiger" +3: "sagidayan" +""" \ No newline at end of file diff --git a/templates/js/controllers/profileController.js b/templates/js/controllers/profileController.js index d07c0b8..670f604 100644 --- a/templates/js/controllers/profileController.js +++ b/templates/js/controllers/profileController.js @@ -8,6 +8,7 @@ angular.module('SeHub') $scope.loadingData = true; $scope.isInRegisterMode = false; $scope.userExists = false; + $scope.isUser = false; $scope.title = "Profile"; @@ -36,6 +37,13 @@ angular.module('SeHub') console.error("++++++++++++++++++++"); }); + $scope.labels = data.stats.labels; + //$scope.series = ['Project A', 'Project B']; + + $scope.data = data.stats.data; + + $scope.isUser = $scope.$parent.user.id.toString() /*The Actual User*/ === $routeParams.id /*The Profile User*/ ; + }); @@ -62,15 +70,7 @@ angular.module('SeHub') } } - $scope.labels = ['Commits', 'Issues Assigned', 'Messages', 'Open Tasks']; - //$scope.series = ['Project A', 'Project B']; - $scope.data = [ - [54, 3, 15, 3] //, - //[28, 48, 40, 3] - ]; - - $scope.isUser = $scope.$parent.user.id.toString() /*The Actual User*/ === $routeParams.id /*The Profile User*/ ; } ]); \ No newline at end of file diff --git a/templates/views/profile.html b/templates/views/profile.html index a4b6769..78bb3e2 100644 --- a/templates/views/profile.html +++ b/templates/views/profile.html @@ -8,7 +8,7 @@

{{title}}

-
+