User Profile - Now Getting Real Stats (commits, issues, messages)

This commit is contained in:
Sagi Dayan 2015-08-01 13:35:59 +03:00
parent 35df7cd3e3
commit c36a4041b6
3 changed files with 69 additions and 10 deletions

View file

@ -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"
"""

View file

@ -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*/ ;
}
]);

View file

@ -8,7 +8,7 @@
<md-card layout-padding>
<h1><i class="fa fa-cogs"></i> {{title}}</h1>
<div layout="row">
<div>
<div flex='40'>
<md-card layout-padding>
<div id="profile" layout="column">
<!-- User Profile Box -->