damned-lies r1354 - in trunk: . languages stats templates templates/languages
- From: claudep svn gnome org
- To: svn-commits-list gnome org
- Subject: damned-lies r1354 - in trunk: . languages stats templates templates/languages
- Date: Fri, 16 Jan 2009 16:41:52 +0000 (UTC)
Author: claudep
Date: Fri Jan 16 16:41:51 2009
New Revision: 1354
URL: http://svn.gnome.org/viewvc/damned-lies?rev=1354&view=rev
Log:
2009-01-16 Claude Paroz <claude 2xlibre net>
* stats/models.py: Add documentation for get_lang_stats_by_type output
structure.
* languages/view.py: Adapted XML output to revised get_lang_stats
structure.
* templates/languages/language_release_stats.html:
* templates/stats_show.html: Use preferably vertimus-by-names URLs.
Fixes bug #567398.
Modified:
trunk/ChangeLog
trunk/languages/views.py
trunk/stats/models.py
trunk/templates/languages/language_release_stats.html
trunk/templates/stats_show.html
Modified: trunk/languages/views.py
==============================================================================
--- trunk/languages/views.py (original)
+++ trunk/languages/views.py Fri Jan 16 16:41:51 2009
@@ -96,29 +96,29 @@
content += "<untranslated>%s</untranslated>" % categ['catuntrans']
# Modules
for modname, mod in categ['modules']:
- content += "<module id=\"%s\" branch=\"%s\">" % (modname, mod[1][1].branch.name)
+ content += "<module id=\"%s\" branch=\"%s\">" % (modname, mod['branch'])
# DOC domains
if catname in stats['doc']['categs'] and stats['doc']['categs'][catname]['modules']:
for docmod in stats['doc']['categs'][catname]['modules']:
if docmod[0] == modname:
- content += get_domain_stats(docmod[1], "document")
+ content += get_domain_stats(docmod[1]['domains'], "document")
# UI stats
- content += get_domain_stats(mod, "domain")
+ content += get_domain_stats(mod['domains'], "domain")
content += "</module>"
# Add modules who have no ui counterparts
if catname == 'dev-tools':
try:
mod = [m for m in stats['doc']['categs']['dev-tools']['modules'] if m[0] == 'gnome-devel-docs'][0][1]
- content += "<module id=\"gnome-devel-docs\" branch=\"%s\">" % mod[1][1].branch.name
- content += get_domain_stats(mod, "document")
+ content += "<module id=\"gnome-devel-docs\" branch=\"%s\">" % mod['branch']
+ content += get_domain_stats(mod['domains'], "document")
content += "</module>"
except:
pass
if catname == 'desktop':
try:
mod = [m for m in stats['doc']['categs']['desktop']['modules'] if m[0] == 'gnome-user-docs'][0][1]
- content += "<module id=\"gnome-user-docs\" branch=\"%s\">" % mod[1][1].branch.name
- content += get_domain_stats(mod, "document")
+ content += "<module id=\"gnome-user-docs\" branch=\"%s\">" % mod['branch']
+ content += get_domain_stats(mod['domains'], "document")
content += "</module>"
except:
pass
Modified: trunk/stats/models.py
==============================================================================
--- trunk/stats/models.py (original)
+++ trunk/stats/models.py Fri Jan 16 16:41:51 2009
@@ -790,9 +790,44 @@
return stats
def get_lang_stats_by_type(self, lang, dtype):
+ """ Cook statistics for an entire release, a domain type dtype and the language lang.
+ Structure of the resulting stats dictionary is as follows:
+ stats = {
+ 'dtype':dtype, # 'ui' or 'doc'
+ 'total': 0,
+ 'totaltrans': 0,
+ 'totalfuzzy': 0,
+ 'totaluntrans': 0,
+ 'totaltransperc': 0,
+ 'totalfuzzyperc': 0,
+ 'totaluntransperc': 0,
+ 'categs': {
+ <categname>: {
+ 'catname': <catname>, # translated category name (see CATEGORY_CHOICES)
+ 'cattotal': 0,
+ 'cattrans': 0,
+ 'catfuzzy': 0,
+ 'catuntrans': 0,
+ 'cattransperc': 0,
+ 'modules': { # This dict is converted to a sorted list at the end of stats computation
+ <modname>: {
+ 'domains': [(<domname>, <stat>), ...], # List of tuples (domain name, Statistics object)
+ # First element is a placeholder for a FakeStatistics object
+ # only used for summary if module has more than 1 domain
+ 'branch': <branch>
+ }
+ }
+ }
+ }
+ },
+ 'all_errors':[]
+ }
+ """
from vertimus.models import StateDb # import here to prevent a circular dependency
- stats = {'dtype':dtype, 'totaltrans':0, 'totalfuzzy':0, 'totaluntrans':0, 'categs':{}, 'all_errors':[]}
+ stats = {'dtype':dtype, 'totaltrans':0, 'totalfuzzy':0, 'totaluntrans':0,
+ 'totaltransperc': 0, 'totalfuzzyperc': 0, 'totaluntransperc': 0,
+ 'categs':{}, 'all_errors':[]}
# Sorted by module to allow grouping ('fake' stats)
pot_stats = Statistics.objects.select_related(depth=1).filter(language=None, branch__releases=self, domain__dtype=dtype).order_by('branch__module__id')
tr_stats = Statistics.objects.select_related(depth=1).filter(language=lang, branch__releases=self, domain__dtype=dtype).order_by('branch__module__id')
@@ -802,8 +837,8 @@
domname = _(stat.domain.description)
modname = stat.branch.module.name
if categdescr not in stats['categs']:
- stats['categs'][categdescr] = {'cattrans':0, 'catfuzzy':0,
- 'catuntrans':0, 'modules':{}}
+ stats['categs'][categdescr] = {'cattrans':0, 'catfuzzy':0, 'catuntrans':0,
+ 'cattransperc':0, 'modules':{}}
# Try to get translated stat, else stick with POT stat
try:
stat = tr_stats.get(branch=stat.branch, domain=stat.domain)
@@ -825,15 +860,15 @@
stats['categs'][categdescr]['catuntrans'] += stat.untranslated
if modname not in stats['categs'][categdescr]['modules']:
# first element is a placeholder for a fake stat
- stats['categs'][categdescr]['modules'][modname] = {' fake':None, domname:stat}
- previous_domname = domname
+ stats['categs'][categdescr]['modules'][modname] = {'domains':[[' fake', None], (domname, stat)],
+ 'branch': stat.branch.name }
else:
- if len(stats['categs'][categdescr]['modules'][modname]) < 3:
+ if len(stats['categs'][categdescr]['modules'][modname]['domains']) == 2:
# Create a fake statistics object for module summary
- stats['categs'][categdescr]['modules'][modname][' fake'] = FakeStatistics(stat.domain.module, dtype)
- stats['categs'][categdescr]['modules'][modname][' fake'].trans(stats['categs'][categdescr]['modules'][modname][previous_domname])
- stats['categs'][categdescr]['modules'][modname][domname] = stat
- stats['categs'][categdescr]['modules'][modname][' fake'].trans(stat)
+ stats['categs'][categdescr]['modules'][modname]['domains'][0][1] = FakeStatistics(stat.domain.module, dtype)
+ stats['categs'][categdescr]['modules'][modname]['domains'][0][1].trans(stats['categs'][categdescr]['modules'][modname]['domains'][1][1])
+ stats['categs'][categdescr]['modules'][modname]['domains'].append((domname, stat))
+ stats['categs'][categdescr]['modules'][modname]['domains'][0][1].trans(stat)
# Compute percentages and sorting
stats['total'] = stats['totaltrans'] + stats['totalfuzzy'] + stats['totaluntrans']
@@ -841,26 +876,18 @@
stats['totaltransperc'] = int(100*stats['totaltrans']/stats['total'])
stats['totalfuzzyperc'] = int(100*stats['totalfuzzy']/stats['total'])
stats['totaluntransperc'] = int(100*stats['totaluntrans']/stats['total'])
- else:
- stats['totaltransperc'] = 0
- stats['totalfuzzyperc'] = 0
- stats['totaluntransperc'] = 0
for key, categ in stats['categs'].items():
categ['catname'] = Category.get_cat_name(key)
categ['cattotal'] = categ['cattrans'] + categ['catfuzzy'] + categ['catuntrans']
if categ['cattotal'] > 0:
categ['cattransperc'] = int(100*categ['cattrans']/categ['cattotal'])
- else:
- categ['cattransperc'] = 0
# Sort modules
mods = [[name,mod] for name, mod in categ['modules'].items()]
mods.sort()
categ['modules'] = mods
# Sort domains
for mod in categ['modules']:
- doms = [(name,dom) for name, dom in mod[1].items()]
- doms.sort()
- mod[1] = doms
+ mod[1]['domains'].sort()
# Sort errors
stats['all_errors'].sort()
return stats
Modified: trunk/templates/languages/language_release_stats.html
==============================================================================
--- trunk/templates/languages/language_release_stats.html (original)
+++ trunk/templates/languages/language_release_stats.html Fri Jan 16 16:41:51 2009
@@ -28,49 +28,51 @@
{% for module in categ.modules %}
{% with module.0 as modname %}
- {% for dom in module.1 %}
+ {% for dom in module.1.domains %}
{% with dom.0 as domname %}
- {% if dom.1 %}
- {% ifequal dom.1.tr_percentage 100 %}
- <tr id="{{ modname }}-{{ domname }}-complete">
+ {% with dom.1 as stat %}
+ {% if stat %}
+ {% ifequal stat.tr_percentage 100 %}
+ <tr id="{{ modname }}-{{ stat.domain.id }}-complete">
{% else %}
<tr>
{% endifequal %}
- {% if dom.1.partial_po %}
+ {% if stat.partial_po %}
{# This is a partial po, indented, with the domain description #}
<td class="leftcell" style="padding-left:2em; padding-right:2em;">
- <a href="{% url vertimus-stats-id-view dom.1.id language.id %}">{{ dom.1.domain.description }}</a>
+ <a href="{% url vertimus-names-view modname module.1.branch stat.domain.name language.locale %}">{{ domname }}</a>
{% else %}
<td class="leftcell">
- {% if not dom.1.is_fake %}
- <a href="{% url vertimus-stats-id-view dom.1.id language.id %}">{{ dom.1.module_description }}</a>
+ {% if not stat.is_fake %}
+ <a href="{% url vertimus-names-view modname module.1.branch stat.domain.name language.locale %}">{{ stat.module_description }}</a>
{% else %}
- <em>{{ dom.1.module_description }}</em>
+ <em>{{ stat.module_description }}</em>
{% endif %}
{% endif %}
- {% for err in dom.1.information_set.all %}
+ {% for err in stat.information_set.all %}
<img src="{{ err.get_icon }}" title="{{ err.get_description }}" alt="{{ err.type }}" />
{% endfor %}
</td>
- <td>{{ dom.1.tr_percentage }}% ({{ dom.1.translated }}/{{ dom.1.fuzzy }}/{{ dom.1.untranslated }})</td>
+ <td>{{ stat.tr_percentage }}% ({{ stat.translated }}/{{ stat.fuzzy }}/{{ stat.untranslated }})</td>
<td style="width: 108px; text-align: center;"><div class="graph">
- <div class="translated" style="width: {{ dom.1.tr_percentage }}px;"></div>
- <div class="fuzzy" style="left:{{ dom.1.tr_percentage }}px; width:{{ dom.1.fu_percentage }}px;"></div>
- {% with dom.1.tr_percentage|add:dom.1.fu_percentage as upos %}
- <div class="untranslated" style="left:{{ upos }}px; width:{{ dom.1.un_percentage }}px;"></div>
+ <div class="translated" style="width: {{ stat.tr_percentage }}px;"></div>
+ <div class="fuzzy" style="left:{{ stat.tr_percentage }}px; width:{{ stat.fu_percentage }}px;"></div>
+ {% with stat.tr_percentage|add:stat.fu_percentage as upos %}
+ <div class="untranslated" style="left:{{ upos }}px; width:{{ stat.un_percentage }}px;"></div>
{% endwith %}
</div>
</td>
<td>
- {% if dom.1.state.name %}
- {% ifnotequal dom.1.state.name "None" %}
- <em><small>{{ dom.1.state.get_state }} - {{ dom.1.state.updated|date:dateformat }}</small></em>
+ {% if stat.state.name %}
+ {% ifnotequal stat.state.name "None" %}
+ <em><small>{{ stat.state.get_state }} - {{ stat.state.updated|date:dateformat }}</small></em>
{% endifnotequal %}
{% endif %}
</td>
</tr>
{% endif %}
{% endwith %}
+ {% endwith %}
{% endfor %}
{% endwith %}
{% endfor %}
Modified: trunk/templates/stats_show.html
==============================================================================
--- trunk/templates/stats_show.html (original)
+++ trunk/templates/stats_show.html Fri Jan 16 16:41:51 2009
@@ -37,7 +37,7 @@
{% for line in stat %}
{% if not forloop.first %}
<tr>
- <td class="leftcell"><a href="{% url vertimus-stats-id-view line.id line.language.id %}">{{ line.get_lang }}</a>
+ <td class="leftcell"><a href="{% url vertimus-names-view module.name branch.name stat1.domain.name line.language.locale %}">{{ line.get_lang }}</a>
{% with line.most_important_message as msg %}
{% if msg %}
<img src="{{ msg.get_icon }}" title="{{ msg.get_description }}" alt="{{ msg.type }}" />
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]