89
from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
90
89
from lp.translations.interfaces.potemplate import IPOTemplateSet
91
90
from lp.translations.model.potmsgset import POTMsgSet
92
91
from lp.translations.model.potranslation import POTranslation
902
901
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_size = int(chunk_size + 0.5)
931
chunk_ids = self.ids[:chunk_size]
932
del self.ids[:chunk_size]
933
self.store.execute("""
934
UPDATE SourcePackageRelease
935
SET dsc_binaries = regexp_replace(
936
dsc_binaries, '([a-z0-9+.-]) ', E'\\\\1, ', 'g')
937
WHERE id IN %s""" % sqlvalues(chunk_ids), noresult=True)
941
904
class SuggestiveTemplatesCacheUpdater(TunableLoop):
942
905
"""Refresh the SuggestivePOTemplate cache.
1302
1265
ObsoleteBugAttachmentPruner,
1303
1266
OldTimeLimitedTokenDeleter,
1304
1267
RevisionAuthorEmailLinker,
1305
SourcePackageReleaseDscBinariesUpdater,
1306
1268
SuggestiveTemplatesCacheUpdater,
1307
1269
POTranslationPruner,
1308
1270
UnusedPOTMsgSetPruner,