damned-lies r1090 - in branches/djamnedlies: . stats templates
- From: claudep svn gnome org
- To: svn-commits-list gnome org
- Subject: damned-lies r1090 - in branches/djamnedlies: . stats templates
- Date: Fri, 24 Oct 2008 10:20:40 +0000 (UTC)
Author: claudep
Date: Fri Oct 24 10:20:39 2008
New Revision: 1090
URL: http://svn.gnome.org/viewvc/damned-lies?rev=1090&view=rev
Log:
2008-10-24 Claude Paroz <claude 2xlibre net>
* TODO: update-stats is now complete.
* settings_sample.py: Use locale middleware.
* stats/models.py: Coerce percentages to int type. Quote release table as
it is a protected word in mysql.
* templates/team.html:
* stats/views.py: team template should be displayable even when there is
no team for a language.
* templates/show-stats.html: Use new description_get function for domain.
Modified:
branches/djamnedlies/ChangeLog
branches/djamnedlies/TODO
branches/djamnedlies/settings_sample.py
branches/djamnedlies/stats/models.py
branches/djamnedlies/stats/views.py
branches/djamnedlies/templates/show-stats.html
branches/djamnedlies/templates/team.html
Modified: branches/djamnedlies/TODO
==============================================================================
--- branches/djamnedlies/TODO (original)
+++ branches/djamnedlies/TODO Fri Oct 24 10:20:39 2008
@@ -1,4 +1,3 @@
Things left to do:
* i18n (translation for strings in database?)
* replace entirely defaults.py by conf/settings.py
- * implement update-stats.py script
Modified: branches/djamnedlies/settings_sample.py
==============================================================================
--- branches/djamnedlies/settings_sample.py (original)
+++ branches/djamnedlies/settings_sample.py Fri Oct 24 10:20:39 2008
@@ -63,6 +63,7 @@
)
MIDDLEWARE_CLASSES = (
+ 'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
Modified: branches/djamnedlies/stats/models.py
==============================================================================
--- branches/djamnedlies/stats/models.py (original)
+++ branches/djamnedlies/stats/models.py Fri Oct 24 10:20:39 2008
@@ -478,6 +478,9 @@
else:
return self.name
+ def get_description(self):
+ return self.description or self.potbase()
+
RELEASE_STATUS_CHOICES = (
('official', 'Official'),
('unofficial', 'Unofficial'),
@@ -498,7 +501,7 @@
LEFT JOIN domain ON domain.id=stat.domain_id
LEFT JOIN branch AS br ON br.id=stat.branch_id
LEFT JOIN category AS cat ON br.category_id=cat.id
- LEFT JOIN release AS rel ON rel.id = cat.release_id
+ LEFT JOIN `release` AS rel ON rel.id = cat.release_id
WHERE rel.id=%s AND stat.language_id IS NULL
GROUP BY domain.dtype """
cursor = connection.cursor()
@@ -537,14 +540,14 @@
stats['docfuzzy'] = res[2]
stats['uiuntrans'] = total_ui - (stats['uitrans'] + stats['uifuzzy'])
if total_ui > 0:
- stats['uitransperc'] = 100*stats['uitrans']/total_ui
- stats['uifuzzyperc'] = 100*stats['uifuzzy']/total_ui
- stats['uiuntransperc'] = 100*stats['uiuntrans']/total_ui
+ stats['uitransperc'] = int(100*stats['uitrans']/total_ui)
+ stats['uifuzzyperc'] = int(100*stats['uifuzzy']/total_ui)
+ stats['uiuntransperc'] = int(100*stats['uiuntrans']/total_ui)
stats['docuntrans'] = total_doc - (stats['doctrans'] + stats['docfuzzy'])
if total_doc > 0:
- stats['doctransperc'] = 100*stats['doctrans']/total_doc
- stats['docfuzzyperc'] = 100*stats['docfuzzy']/total_doc
- stats['docuntransperc'] = 100*stats['docuntrans']/total_doc
+ stats['doctransperc'] = int(100*stats['doctrans']/total_doc)
+ stats['docfuzzyperc'] = int(100*stats['docfuzzy']/total_doc)
+ stats['docuntransperc'] = int(100*stats['docuntrans']/total_doc)
return stats
def get_global_stats(self):
@@ -576,16 +579,16 @@
stats[row[1]]['doc_trans'] = row[3]
stats[row[1]]['doc_fuzzy'] = row[4]
stats[row[1]]['doc_untrans'] = total_docstrings - (row[3] + row[4])
- stats[row[1]]['doc_percent'] = 100*row[3]/total_docstrings
- stats[row[1]]['doc_percentfuzzy'] = 100*row[4]/total_docstrings
- stats[row[1]]['doc_percentuntrans'] = 100*stats[row[1]]['doc_untrans']/total_docstrings
+ stats[row[1]]['doc_percent'] = int(100*row[3]/total_docstrings)
+ stats[row[1]]['doc_percentfuzzy'] = int(100*row[4]/total_docstrings)
+ stats[row[1]]['doc_percentuntrans'] = int(100*stats[row[1]]['doc_untrans']/total_docstrings)
if row[2] == 'ui':
stats[row[1]]['ui_trans'] = row[3]
stats[row[1]]['ui_fuzzy'] = row[4]
stats[row[1]]['ui_untrans'] = total_uistrings - (row[3] + row[4])
- stats[row[1]]['ui_percent'] = 100*row[3]/total_uistrings
- stats[row[1]]['ui_percentfuzzy'] = 100*row[4]/total_uistrings
- stats[row[1]]['ui_percentuntrans'] = 100*stats[row[1]]['ui_untrans']/total_uistrings
+ stats[row[1]]['ui_percent'] = int(100*row[3]/total_uistrings)
+ stats[row[1]]['ui_percentfuzzy'] = int(100*row[4]/total_uistrings)
+ stats[row[1]]['ui_percentuntrans'] = int(100*stats[row[1]]['ui_untrans']/total_uistrings)
cursor.close()
results = [stat for key, stat in stats.items()]
results.sort(self.compare_stats)
@@ -653,16 +656,16 @@
for dtype in ['ui', 'doc']:
stats[dtype]['total'] = stats[dtype]['totaltrans'] + stats[dtype]['totalfuzzy'] + stats[dtype]['totaluntrans']
if stats[dtype]['total'] > 0:
- stats[dtype]['totaltransperc'] = 100*stats[dtype]['totaltrans']/stats[dtype]['total']
- stats[dtype]['totalfuzzyperc'] = 100*stats[dtype]['totalfuzzy']/stats[dtype]['total']
- stats[dtype]['totaluntransperc'] = 100*stats[dtype]['totaluntrans']/stats[dtype]['total']
+ stats[dtype]['totaltransperc'] = int(100*stats[dtype]['totaltrans']/stats[dtype]['total'])
+ stats[dtype]['totalfuzzyperc'] = int(100*stats[dtype]['totalfuzzy']/stats[dtype]['total'])
+ stats[dtype]['totaluntransperc'] = int(100*stats[dtype]['totaluntrans']/stats[dtype]['total'])
else:
stats[dtype]['totaltransperc'] = 0
stats[dtype]['totalfuzzyperc'] = 0
stats[dtype]['totaluntransperc'] = 0
for key, categ in stats[dtype]['categs'].items():
categ['cattotal'] = categ['cattrans'] + categ['catfuzzy'] + categ['catuntrans']
- categ['cattransperc'] = 100*categ['cattrans']/categ['cattotal']
+ categ['cattransperc'] = int(100*categ['cattrans']/categ['cattotal'])
# Sort modules
mods = [[name,mod] for name, mod in categ['modules'].items()]
mods.sort()
@@ -721,19 +724,19 @@
if self.pot_size() == 0:
return 0
else:
- return 100*self.Translated/self.pot_size()
+ return int(100*self.Translated/self.pot_size())
def fu_percentage(self):
if self.pot_size() == 0:
return 0
else:
- return 100*self.Fuzzy/self.pot_size()
+ return int(100*self.Fuzzy/self.pot_size())
def un_percentage(self):
if self.pot_size() == 0:
return 0
else:
- return 100*self.Untranslated/self.pot_size()
+ return int(100*self.Untranslated/self.pot_size())
def get_lang(self):
if self.language:
@@ -780,6 +783,9 @@
# Extract image strings: beforeline/msgid/msgstr/grep auto output a fourth line
command = "msgcat --no-wrap %(pofile)s| grep -A 1 -B 1 '^msgid \"@@image:'" % { 'pofile': self.po_path() }
(error, output) = commands.getstatusoutput(command)
+ if error:
+ # FIXME: something should be logged here
+ return []
lines = output.split('\n')
re_path = re.compile('^msgid \"@@image: \'([^\']*)\'')
self.figures = []
@@ -850,11 +856,6 @@
if not error or e.Type == 'error' or (e.Type == 'warn' and error.Type == 'info'):
error = e
return error
-
- def update(self):
- """ Update stats in database """
- # TODO
- print("Updating %s/%s (%s-%s)" % (self.branch.module.name, self.branch.name, self.get_lang(), self.domain.name))
class FakeStatistics(object):
""" This is a fake statistics class where a summary value is needed for a multi-domain module
@@ -887,17 +888,17 @@
if self.pot_size() == 0:
return 0
else:
- return 100*self.Translated/self.pot_size()
+ return int(100*self.Translated/self.pot_size())
def fu_percentage(self):
if self.pot_size() == 0:
return 0
else:
- return 100*self.Fuzzy/self.pot_size()
+ return int(100*self.Fuzzy/self.pot_size())
def un_percentage(self):
if self.pot_size() == 0:
return 0
else:
- return 100*self.Untranslated/self.pot_size()
+ return int(100*self.Untranslated/self.pot_size())
def module_name(self):
return self.module.name
def module_description(self):
Modified: branches/djamnedlies/stats/views.py
==============================================================================
--- branches/djamnedlies/stats/views.py (original)
+++ branches/djamnedlies/stats/views.py Fri Oct 24 10:20:39 2008
@@ -21,13 +21,13 @@
from django.shortcuts import render_to_response
from stats.models import Statistics, Team, Language, Person, Module, Release
from stats.conf import settings
-from djamnedlies.stats import utils, defaults
+from djamnedlies.stats import utils
from django.http import HttpResponse
from django.utils.translation import ugettext_lazy as _
def index(request):
translator_credit = _("translator-credits")
- if defaults.language == 'en' or translator_credit == "translator-credits":
+ if request.LANGUAGE_CODE == 'en' or translator_credit == "translator-credits":
translator_credit = ""
else:
translator_credit.replace("\n", ", ").replace("<", "<").replace(">", ">")
@@ -48,10 +48,18 @@
return render_to_response('list-teams.html', context)
def team(request, name):
- team = Team.objects.get(name=name)
+ try:
+ team = Team.objects.get(name=name)
+ languages = team.language_set.all()
+ except:
+ # In the case there is no team for a language
+ language = Language.objects.get(locale=name)
+ team = {'description': name}
+ languages = [language]
context = {'pageSection': "teams",
'webroot': settings.WEBROOT,
- 'team': team}
+ 'team': team,
+ 'languages': languages}
return render_to_response('team.html', context)
def languages(request):
Modified: branches/djamnedlies/templates/show-stats.html
==============================================================================
--- branches/djamnedlies/templates/show-stats.html (original)
+++ branches/djamnedlies/templates/show-stats.html Fri Oct 24 10:20:39 2008
@@ -2,7 +2,7 @@
{% for dname, stat in stats.items %}
{% with stat|first as stat1 %}
- <h3>{% trans stat1.domain.description %}
+ <h3>{% trans stat1.domain.get_description %}
{% ifnotequal stat1.domain.directory 'help' %}
{% ifnotequal stat1.domain.directory 'po' %}
<br /><span class='path'>{{ stat1.domain.directory }}</span>
Modified: branches/djamnedlies/templates/team.html
==============================================================================
--- branches/djamnedlies/templates/team.html (original)
+++ branches/djamnedlies/templates/team.html Fri Oct 24 10:20:39 2008
@@ -44,7 +44,7 @@
{% endif %}
</td></tr></table>
-{% for lang in team.language_set.all %}
+{% for lang in languages %}
<h2>{% trans lang.name %}</h2>
<table class="stats">
<thead><tr><th>{% trans "Release" %}</th><th>{% trans "Documentation" %}</th><th>{% trans "Graph" %}</th>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]