~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/scripts/garbo.py

[r=wgrant][bug=810727] Do not create packaging links in
        BugAlsoAffectsView if the distribution we get from the DSP task
        on the bugtask has no currentseries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2009-2012 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 
4
4
"""Database garbage collection."""
85
85
    MAIN_STORE,
86
86
    MASTER_FLAVOR,
87
87
    )
88
 
from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
89
88
from lp.translations.interfaces.potemplate import IPOTemplateSet
90
89
from lp.translations.model.potmsgset import POTMsgSet
91
90
from lp.translations.model.potranslation import POTranslation
876
875
        self._update_oldest()
877
876
 
878
877
 
879
 
class SourcePackageReleaseDscBinariesUpdater(TunableLoop):
880
 
    """Fix incorrect values for SourcePackageRelease.dsc_binaries."""
881
 
 
882
 
    maximum_chunk_size = 1000
883
 
 
884
 
    def __init__(self, log, abort_time=None):
885
 
        super(SourcePackageReleaseDscBinariesUpdater, self).__init__(
886
 
            log, abort_time)
887
 
        self.store = IMasterStore(SourcePackageRelease)
888
 
        self.ids = list(
889
 
            self.store.find(
890
 
                SourcePackageRelease.id,
891
 
                # Get all SPR IDs which have an incorrectly-separated
892
 
                # dsc_binaries value (space rather than comma-space).
893
 
                SQL("dsc_binaries ~ '[a-z0-9+.-] '"),
894
 
                # Skip rows with dsc_binaries in dependency relationship
895
 
                # format.  This is a different bug.
896
 
                SQL("dsc_binaries NOT LIKE '%(%'")))
897
 
 
898
 
    def isDone(self):
899
 
        """See `TunableLoop`."""
900
 
        return len(self.ids) == 0
901
 
 
902
 
    def __call__(self, chunk_size):
903
 
        """See `TunableLoop`."""
904
 
        chunk_size = int(chunk_size + 0.5)
905
 
        chunk_ids = self.ids[:chunk_size]
906
 
        del self.ids[:chunk_size]
907
 
        self.store.execute("""
908
 
            UPDATE SourcePackageRelease
909
 
            SET dsc_binaries = regexp_replace(
910
 
                dsc_binaries, '([a-z0-9+.-]) ', E'\\\\1, ', 'g')
911
 
            WHERE id IN %s""" % sqlvalues(chunk_ids), noresult=True)
912
 
        transaction.commit()
913
 
 
914
 
 
915
878
class SuggestiveTemplatesCacheUpdater(TunableLoop):
916
879
    """Refresh the SuggestivePOTemplate cache.
917
880
 
1276
1239
        ObsoleteBugAttachmentPruner,
1277
1240
        OldTimeLimitedTokenDeleter,
1278
1241
        RevisionAuthorEmailLinker,
1279
 
        SourcePackageReleaseDscBinariesUpdater,
1280
1242
        SuggestiveTemplatesCacheUpdater,
1281
1243
        POTranslationPruner,
1282
1244
        UnusedPOTMsgSetPruner,