89
from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
89
90
from lp.translations.interfaces.potemplate import IPOTemplateSet
90
91
from lp.translations.model.potmsgset import POTMsgSet
91
92
from lp.translations.model.potranslation import POTranslation
901
902
self._update_oldest()
905
class SourcePackageReleaseDscBinariesUpdater(TunableLoop):
906
"""Fix incorrect values for SourcePackageRelease.dsc_binaries."""
908
maximum_chunk_size = 1000
910
def __init__(self, log, abort_time=None):
911
super(SourcePackageReleaseDscBinariesUpdater, self).__init__(
913
self.store = IMasterStore(SourcePackageRelease)
916
SourcePackageRelease.id,
917
# Get all SPR IDs which have an incorrectly-separated
918
# dsc_binaries value (space rather than comma-space).
919
SQL("dsc_binaries ~ '[a-z0-9+.-] '"),
920
# Skip rows with dsc_binaries in dependency relationship
921
# format. This is a different bug.
922
SQL("dsc_binaries NOT LIKE '%(%'")))
925
"""See `TunableLoop`."""
926
return len(self.ids) == 0
928
def __call__(self, chunk_size):
929
"""See `TunableLoop`."""
930
chunk_ids = self.ids[:chunk_size]
931
del self.ids[:chunk_size]
932
self.store.execute("""
933
UPDATE SourcePackageRelease
934
SET dsc_binaries = regexp_replace(
935
dsc_binaries, '([a-z0-9+.-]) ', E'\\\\1, ', 'g')
936
WHERE id IN %s""" % sqlvalues(chunk_ids), noresult=True)
904
940
class SuggestiveTemplatesCacheUpdater(TunableLoop):
905
941
"""Refresh the SuggestivePOTemplate cache.
1265
1301
ObsoleteBugAttachmentPruner,
1266
1302
OldTimeLimitedTokenDeleter,
1267
1303
RevisionAuthorEmailLinker,
1304
SourcePackageReleaseDscBinariesUpdater,
1268
1305
SuggestiveTemplatesCacheUpdater,
1269
1306
POTranslationPruner,
1270
1307
UnusedPOTMsgSetPruner,