diff options
| author | Claude Paroz <claude@2xlibre.net> | 2011-08-31 09:05:14 (GMT) |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2011-08-31 09:05:14 (GMT) |
| commit | 6b3df0e0bbd5bf847a7711f854ee5c073f31c9df (patch) | |
| tree | ca14711bec4d5d4c6f10bbd340e6aa65b0fbf63c | |
| parent | c5381a1e9ecc3f4abe7cd7eaf118e0a701619b34 (diff) | |
| download | damned-lies-6b3df0e0.zip damned-lies-6b3df0e0.tar.xz | |
Delete stats when they exist no more on the file system (Fixes #657685)
| -rw-r--r-- | stats/models.py | 7 | ||||
| -rw-r--r-- | stats/tests/__init__.py | 3 |
2 files changed, 9 insertions, 1 deletions
diff --git a/stats/models.py b/stats/models.py index cdd2a38..269bbc9 100644 --- a/stats/models.py +++ b/stats/models.py @@ -470,7 +470,8 @@ class Branch(models.Model): command = "msgmerge --previous -o %(outpo)s %(pofile)s %(potfile)s" stats_with_ext_errors = Statistics.objects.filter(branch=self, domain=dom, information__type__endswith='-ext') langs_with_ext_errors = [stat.language.locale for stat in stats_with_ext_errors] - for lang, pofile in dom.get_lang_files(self.co_path()): + dom_langs = dom.get_lang_files(self.co_path()) + for lang, pofile in dom_langs: outpo = os.path.join(self.output_dir(dom.dtype), dom.potbase() + "." + self.name + "." + lang + ".po") if not force and changed_status in (utils.NOT_CHANGED, utils.CHANGED_ONLY_FORMATTING) and os.access(outpo, os.R_OK) \ @@ -520,6 +521,10 @@ class Branch(models.Model): figstats=fig_stats) for err in langstats['errors']: stat.information_set.add(Information(type=err[0], description=err[1])) + # Delete stats for unexisting langs + Statistics.objects.filter(branch=self, domain=dom + ).exclude(models.Q(language__isnull=True) | models.Q(language__locale__in=[dl[0] for dl in dom_langs]) + ).delete() # Check if doap file changed if self.is_head() and self.file_changed("%s.doap" % self.module.name): update_doap_infos(self.module) diff --git a/stats/tests/__init__.py b/stats/tests/__init__.py index 461716a..595e6a9 100644 --- a/stats/tests/__init__.py +++ b/stats/tests/__init__.py @@ -82,6 +82,8 @@ class ModuleTestCase(TestCase): self.assertEqual(self.branch.get_vcs_web_url(), "http://git.gnome.org/browse/gnome-hello/") def testBranchStats(self): + lang = Language.objects.create(name='xxx', locale='xxx') + ghost_stat = Statistics.objects.create(branch=self.branch, domain=self.mod.domain_set.get(name='po'), language=lang) # Check stats self.branch.update_stats(force=True) fr_po_stat = Statistics.objects.get(branch=self.branch, domain__name='po', language__locale='fr') @@ -91,6 +93,7 @@ class ModuleTestCase(TestCase): self.assertEqual(fr_po_stat.po_url(), u"/POT/gnome-hello.master/gnome-hello.master.fr.po") self.assertEqual(fr_po_stat.pot_url(), u"/POT/gnome-hello.master/gnome-hello.master.pot") self.assertEqual(fr_doc_stat.po_url(), u"/POT/gnome-hello.master/docs/gnome-hello-help.master.fr.po") + self.assertRaises(Statistics.DoesNotExist, Statistics.objects.get, pk=ghost_stat.pk) def testCreateAndDeleteBranch(self): Branch.checkout_on_creation = True |
