incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [31/48] git commit: [5453] Fixed stats template and improved controller
Date Thu, 21 Mar 2013 14:22:07 GMT
[5453] Fixed stats template and improved controller


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/7fdca7a1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/7fdca7a1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/7fdca7a1

Branch: refs/heads/si/5453
Commit: 7fdca7a19d98bb22f89174d9bfaa06654c019f0c
Parents: 4c2fdbe
Author: Stefano Invernizzi <stefanoinve@apache.org>
Authored: Wed Jan 30 16:21:49 2013 +0100
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Thu Mar 21 14:16:18 2013 +0000

----------------------------------------------------------------------
 .../forgeuserstats/controllers/userstats.py        |   33 +++++++--------
 ForgeUserStats/forgeuserstats/templates/index.html |   12 +++---
 2 files changed, 21 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7fdca7a1/ForgeUserStats/forgeuserstats/controllers/userstats.py
----------------------------------------------------------------------
diff --git a/ForgeUserStats/forgeuserstats/controllers/userstats.py b/ForgeUserStats/forgeuserstats/controllers/userstats.py
index fe14449..b84eb0f 100644
--- a/ForgeUserStats/forgeuserstats/controllers/userstats.py
+++ b/ForgeUserStats/forgeuserstats/controllers/userstats.py
@@ -15,16 +15,15 @@ class ForgeUserStatsController(BaseController):
         if not self.user:
             return ForgeUserStatsController(user=user), remainder
         if part == "category":
-            return ForgeUserStatsCatController(self.user, self.stats, None), remainder
+            return ForgeUserStatsCatController(self.user, None), remainder
         if part == "metric":
-            return ForgeUserStatsMetricController(self.user, self.stats), remainder
+            return ForgeUserStatsMetricController(self.user), remainder
 
     def __init__(self, user=None):
         self.user = user
         if self.user:
-            self.stats = self.user.stats
-            if not self.stats:
-                self.stats = UserStats.create(self.user)
+            if not user.stats:
+                UserStats.create(self.user)
 
         super(ForgeUserStatsController, self).__init__()
 
@@ -33,7 +32,7 @@ class ForgeUserStatsController(BaseController):
     def index(self, **kw):
         if not self.user: 
             return dict(user=None)
-        stats = self.stats
+        stats = self.user.stats
 
         ret_dict = _getDataForCategory(None, stats)
         ret_dict['user'] = self.user
@@ -107,25 +106,24 @@ class ForgeUserStatsController(BaseController):
 
     @expose()
     def code_ranking_bar(self):
-        return create_progress_bar(self.stats.codeRanking())
+        return create_progress_bar(self.user.stats.codeRanking())
 
     @expose()
     def discussion_ranking_bar(self):
-        return create_progress_bar(self.stats.discussionRanking())
+        return create_progress_bar(self.user.stats.discussionRanking())
 
     @expose()
     def tickets_ranking_bar(self):
-        return create_progress_bar(self.stats.ticketsRanking())
+        return create_progress_bar(self.user.stats.ticketsRanking())
 
 class ForgeUserStatsCatController(BaseController):
     @expose()
     def _lookup(self, category, *remainder):
-        cat = M.TroveCategory.query.get(fullname=category)
+        cat = M.TroveCategory.query.get(shortname=category)
         return ForgeUserStatsCatController(self.user, cat), remainder
 
-    def __init__(self, user, stats, category):
+    def __init__(self, user, category):
         self.user = user
-        self.stats = stats
         self.category = category
         super(ForgeUserStatsCatController, self).__init__()
 
@@ -134,7 +132,7 @@ class ForgeUserStatsCatController(BaseController):
     def index(self, **kw):
         if not self.user:
             return dict(user=None)
-        stats = self.stats
+        stats = self.user.stats
         
         cat_id = None
         if self.category: 
@@ -148,9 +146,8 @@ class ForgeUserStatsCatController(BaseController):
 
 class ForgeUserStatsMetricController(BaseController):
 
-    def __init__(self, user, stats):
+    def __init__(self, user):
         self.user = user
-        self.stats = stats
         super(ForgeUserStatsMetricController, self).__init__()
 
     @expose('jinja:forgeuserstats:templates/commits.html')
@@ -158,7 +155,7 @@ class ForgeUserStatsMetricController(BaseController):
     def commits(self, **kw):
         if not self.user:
             return dict(user=None)
-        stats = self.stats
+        stats = self.user.stats
         
         commits = stats.getCommitsByCategory()
         return dict(user = self.user,
@@ -170,7 +167,7 @@ class ForgeUserStatsMetricController(BaseController):
         if not self.user:
             return dict(user=None)
 
-        stats = self.stats       
+        stats = self.user.stats       
         artifacts = stats.getArtifactsByCategory(detailed=True)
         return dict(user = self.user, data = artifacts) 
 
@@ -180,7 +177,7 @@ class ForgeUserStatsMetricController(BaseController):
         if not self.user: 
             return dict(user=None)
 
-        artifacts = self.stats.getTicketsByCategory()
+        artifacts = self.user.stats.getTicketsByCategory()
         return dict(user = self.user, data = artifacts) 
 
 def _getDataForCategory(category, stats):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7fdca7a1/ForgeUserStats/forgeuserstats/templates/index.html
----------------------------------------------------------------------
diff --git a/ForgeUserStats/forgeuserstats/templates/index.html b/ForgeUserStats/forgeuserstats/templates/index.html
index f5a71c6..6d6a25b 100644
--- a/ForgeUserStats/forgeuserstats/templates/index.html
+++ b/ForgeUserStats/forgeuserstats/templates/index.html
@@ -85,9 +85,9 @@
           <td>{{lastmonthcommits.number}}</td>
           {% if days >= 30 %}
             <td style="text-align:center;">
-              {% if permonthcommits.number > permonthcommits.number %}
+              {% if lastmonthcommits.number > permonthcommits.number %}
                   <img src="{{g.forge_static('images/up.png')}}"/>
-              {% elif permonthcommits.number == permonthcommits.number %}
+              {% elif lastmonthcommits.number == permonthcommits.number %}
                 <img src="{{g.forge_static('images/equal.png')}}"/>
               {% else %}
                 <img src="{{g.forge_static('images/down.png')}}"/>
@@ -108,9 +108,9 @@
           <td>{{lastmonthcommits.lines}}</td>
           {% if days >= 30 %}
             <td style="text-align:center;">
-              {% if permonthcommits.lines > permonthcommits.lines %}
+              {% if lastmonthcommits.lines > permonthcommits.lines %}
                   <img src="{{g.forge_static('images/up.png')}}"/>
-              {% elif permonthcommits.lines == permonthcommits.lines %}
+              {% elif lastmonthcommits.lines == permonthcommits.lines %}
                 <img src="{{g.forge_static('images/equal.png')}}"/>
               {% else %}
                 <img src="{{g.forge_static('images/down.png')}}"/>
@@ -193,7 +193,7 @@
                   {% else %}
                     <img src="{{g.forge_static('images/down.png')}}"/>
                   {%endif%}
-                {%else%} Down {%endif%}
+                {%else%} <img src="{{g.forge_static('images/down.png')}}"/> {%endif%}
               </td>
             {% endif %}
           </tr>
@@ -224,7 +224,7 @@
                   {% else %}
                     <img src="{{g.forge_static('images/down.png')}}"/>
                   {%endif%}
-                {%else%} Down {%endif%}
+                {%else%} <img src="{{g.forge_static('images/down.png')}}"/> {%endif%}
               </td>
             {% endif %}
           </tr>


Mime
View raw message