[damned-lies] Improve release comparison stats
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Improve release comparison stats
- Date: Fri, 6 Aug 2010 20:30:44 +0000 (UTC)
commit 823715316d0738b26ff1daa605236d6edd3b067d
Author: Claude Paroz <claude 2xlibre net>
Date: Fri Aug 6 22:03:49 2010 +0200
Improve release comparison stats
Fixes andre's rant :-)
http://blogs.gnome.org/aklapper/2010/08/02/identifying-teams-in-need/
media/css/main.css | 3 +++
stats/models.py | 14 +++++++++-----
stats/views.py | 11 ++++++++---
templates/release_compare.html | 16 ++++++++--------
urls.py | 2 +-
5 files changed, 29 insertions(+), 17 deletions(-)
---
diff --git a/media/css/main.css b/media/css/main.css
index 6febab7..80fdef5 100644
--- a/media/css/main.css
+++ b/media/css/main.css
@@ -326,3 +326,6 @@ ul.errorlist {
color: #aaaaaa;
}
+.hidden {
+ display: none;
+}
diff --git a/stats/models.py b/stats/models.py
index 3af0494..59e3a5b 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -767,7 +767,10 @@ class Release(models.Model):
""" Get summary stats for all languages and 'releases', and return a 'stats' dict with
each language locale as the key:
stats{
- 'll': (<language name>, percentage for release 1, percentage for release 2, ...),
+ 'll': {'lang': <language object>,
+ 'stats': [percentage for release 1, percentage for release 2, ...],
+ 'diff': difference in % between first and last release,
+ }
'll': ...
}
"""
@@ -796,16 +799,17 @@ class Release(models.Model):
stats = {}; totals = [0] * len(releases)
for row in cursor.fetchall():
if row[LOCALE] and row[LOCALE] not in stats:
- stats[row[LOCALE]] = [0] * len(releases)
- stats[row[LOCALE]].insert(0, _(row[NAME])) # translated language name
+ stats[row[LOCALE]] = {'lang': Language.objects.get(locale=row[LOCALE]),
+ 'stats': [0] * len(releases)}
if row[LOCALE] is None: # POT stats
totals[rel_ids.index(str(row[REL_ID]))] = row[UNTRANS]
else:
- stats[row[LOCALE]][rel_ids.index(str(row[REL_ID]))+1] = row[TRANS]
+ stats[row[LOCALE]]['stats'][rel_ids.index(str(row[REL_ID]))] = row[TRANS]
# Compute percentages
def perc(x, y): return int(x/y * 100)
for k in stats.keys():
- stats[k] = [stats[k][0]] + map(perc, stats[k][1:], totals)
+ stats[k]['stats'] = map(perc, stats[k]['stats'], totals)
+ stats[k]['diff'] = stats[k]['stats'][-1] - stats[k]['stats'][0]
return stats
def total_strings(self):
diff --git a/stats/views.py b/stats/views.py
index 4427c8f..8421526 100644
--- a/stats/views.py
+++ b/stats/views.py
@@ -251,9 +251,14 @@ def release(request, release_name, format='html'):
def compare_by_releases(request, dtype, rels_to_compare):
releases = []
- for rel_id in rels_to_compare.split("-"):
- # Important to keep the ordering of the url
- releases.append(Release.objects.get(id=rel_id))
+ try:
+ if "/" in rels_to_compare:
+ # This is release names
+ releases = [Release.objects.get(name='gnome-%s' % rel_name) for rel_name in rels_to_compare.split("/")]
+ else:
+ releases = [Release.objects.get(id=rel_id) for rel_id in rels_to_compare.split("-")]
+ except Release.DoesNotExist:
+ raise Http404
stats = Release.total_by_releases(dtype, releases)
context = {
'releases': releases,
diff --git a/templates/release_compare.html b/templates/release_compare.html
index d376b6f..c1b75a0 100644
--- a/templates/release_compare.html
+++ b/templates/release_compare.html
@@ -26,20 +26,20 @@ $(document).ready(function()
{% for rel in releases %}
<th class="header">{{ rel.name }}</th>
{% endfor %}
+ <th class="header">{% trans "Progress" %}</th>
</tr>
</thead>
{% for locale, stat in stats.items %}
<tr class="stats">
- {% for perc in stat %}
- {% if forloop.first %}
- <td class="stats leftcell">
- {{ perc }} ({{ locale }})
- </td>
- {% else %}
- <td class="stats {{ perc|support_class }}">{{ perc }}%</td>
- {% endif %}
+ <td class="stats leftcell">
+ <span class="hidden">{{ stat.lang.get_name }}</span><!-- for sorting purpose -->
+ <a href="{{ perc.get_team_url }}">{{ stat.lang.get_name }}</a> ({{ locale }})
+ </td>
+ {% for perc in stat.stats %}
+ <td class="stats {{ perc|support_class }}">{{ perc }}%</td>
{% endfor %}
+ <td class="stats">{{ stat.diff }}%</td>
</tr>
{% endfor %}
</table>
diff --git a/urls.py b/urls.py
index dbdd225..e83db7c 100644
--- a/urls.py
+++ b/urls.py
@@ -80,7 +80,7 @@ urlpatterns += patterns('stats.views',
regex = r'^releases/(?P<release_name>[\w-]+)/(?P<format>(html|xml))?/?$',
view = 'release'),
url(
- regex = r'^releases/compare/(?P<dtype>\w+)/(?P<rels_to_compare>[\w-]+)/$',
+ regex = r'^releases/compare/(?P<dtype>\w+)/(?P<rels_to_compare>[/\w-]+)/$',
view = 'compare_by_releases'),
)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]