Skip to content
Browse files

[bug 773017] Tweak the l10n dashboard queries.

* Exclude redirects in the overview section
* Include translations without approved revisions in the Untranslated section
  • Loading branch information...
1 parent 4a5fc2f commit 7762caa3ebeda7eab570a4065bf4d58959371607 @rlr rlr committed Mar 21, 2013
Showing with 56 additions and 2 deletions.
  1. +10 −2 apps/dashboards/readouts.py
  2. +46 −0 apps/dashboards/tests/test_readouts.py
View
12 apps/dashboards/readouts.py
@@ -21,7 +21,7 @@
from sumo.redis_utils import redis_client, RedisError
from wiki.models import Document
from wiki.config import (MEDIUM_SIGNIFICANCE, MAJOR_SIGNIFICANCE,
- TYPO_SIGNIFICANCE)
+ TYPO_SIGNIFICANCE, REDIRECT_HTML)
log = logging.getLogger('k.dashboards.readouts')
@@ -169,6 +169,8 @@ def single_result(sql, params):
current_revision__isnull=False,
is_localizable=True,
latest_localizable_revision__isnull=False)
+ total = total.exclude(
+ html__startswith=REDIRECT_HTML)
if product:
total = total.filter(products=product)
@@ -202,6 +204,7 @@ def single_result(sql, params):
'AND NOT transdoc.is_archived '
'AND engdoc.latest_localizable_revision_id IS NOT NULL '
'AND engdoc.is_localizable '
+ 'AND engdoc.html NOT LIKE "<p>REDIRECT <a%%" '
'AND NOT EXISTS ' +
ANY_SIGNIFICANT_UPDATES)
translated_docs = single_result(
@@ -611,6 +614,10 @@ def _format_row(self, (eng_slug, eng_title, slug, title, significance,
class UntranslatedReadout(Readout):
title = _lazy(u'Untranslated')
+ description = _lazy(
+ u'This indicates there are no approved translations of these articles. '
+ 'Some of the articles may have proposed translations waiting to be '
+ 'reviewed and will appear in the Unreviewed Changes section as well.')
short_title = _lazy(u'Untranslated')
details_link_text = _lazy(u'All untranslated articles...')
slug = 'untranslated'
@@ -646,7 +653,8 @@ def _query_and_params(self, max):
'dashboards_wikidocumentvisits.period=%s '
+ extra_joins +
'WHERE '
- 'translated.id IS NULL AND engdoc.is_localizable AND '
+ '(translated.id IS NULL OR translated.current_revision_id IS NULL) '
+ 'AND engdoc.is_localizable AND '
'engdoc.category in (10, 20, 60) AND '
'engdoc.locale=%s AND NOT engdoc.is_archived '
'AND wiki_revision.content NOT LIKE "REDIRECT%%" '
View
46 apps/dashboards/tests/test_readouts.py
@@ -43,6 +43,7 @@ def titles(self, locale=None, product=None):
class OverviewTests(TestCase):
"""Tests for Overview readout"""
+
def test_counting_unready_templates(self):
"""Templates without a ready-for-l10n rev shouldn't count in total."""
# Make a template with an approved but not-ready-for-l10n rev:
@@ -220,6 +221,25 @@ def test_by_product(self):
eq_(1, overview_rows('de', product=p)['all']['numerator'])
eq_(1, overview_rows('de', product=p)['all']['denominator'])
+ def test_redirects_are_ignored(self):
+ """Verify that redirects aren't counted in the overview."""
+ t = translated_revision(is_approved=True, save=True)
+
+ eq_(1, overview_rows('de')['all']['numerator'])
+
+ # A redirect shouldn't affect any of the tests.
+ revision(document=document(title='A redirect',
+ is_localizable=True,
+ is_template=True,
+ save=True),
+ is_ready_for_localization=True,
+ is_approved=True,
+ content='REDIRECT [[An article]]',
+ save=True)
+
+ eq_(1, overview_rows('de')['all']['numerator'])
+
+
class UnreviewedChangesTests(ReadoutTestCase):
"""Tests for the Unreviewed Changes readout
@@ -703,3 +723,29 @@ def test_by_product(self):
# Add the product to the document, and verify it shows up.
d.products.add(p)
eq_(self.row(product=p)['title'], d.title)
+
+ def test_deferred_translation(self):
+ """Verify a translation with only a deferred revision appears."""
+ d = document(title='Foo', save=True)
+ untranslated = revision(is_approved=True,
+ is_ready_for_localization=True,
+ document=d,
+ save=True)
+
+ # There should be 1.
+ eq_(1, len(self.titles(locale='es')))
+
+ translation = document(
+ parent=untranslated.document, locale='es', save=True)
+ deferred = revision(is_approved=False,
+ reviewed=datetime.now(),
+ document=translation,
+ save=True)
+
+ # There should still be 1.
+ eq_(1, len(self.titles(locale='es')))
+
+ # Mark that rev as approved and there should then be 0.
+ deferred.is_approved = True
+ deferred.save()
+ eq_(0, len(self.titles(locale='es')))

0 comments on commit 7762caa

Please sign in to comment.
Something went wrong with that request. Please try again.