36
34
IDistroSeriesDifferenceJobSource,
38
36
from lp.soyuz.interfaces.packageset import IPackagesetSet
39
from lp.soyuz.interfaces.publishing import active_publishing_status
40
37
from lp.soyuz.model.distributionjob import (
42
39
DistributionJobDerived,
44
from lp.soyuz.model.publishing import SourcePackagePublishingHistory
45
from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
48
43
FEATURE_FLAG_ENABLE_MODULE = u"soyuz.derived_series_jobs.enabled"
83
78
return DistroSeriesDifferenceJob(job)
86
def create_multiple_jobs(derived_series, parent_series):
87
"""Create a `DistroSeriesDifferenceJob` for all the source packages in
88
archive (optionally limited to the sourcepackagenames passed).
90
:param derived_series: A `DistroSeries` that is assumed to be derived
92
:param parent_series: A `DistroSeries` that is a parent of
94
:param archive: A `IArchive` where to find the source packages.
96
store = IStore(SourcePackageRelease)
97
source_package_releases = store.find(
100
SourcePackagePublishingHistory.sourcepackagerelease ==
101
SourcePackageRelease.id,
102
SourcePackagePublishingHistory.distroseries == derived_series.id,
103
SourcePackagePublishingHistory.status.is_in(
104
active_publishing_status)))
105
nb_jobs = source_package_releases.count()
106
sourcepackagenames = source_package_releases.values(
107
SourcePackageRelease.sourcepackagenameID)
108
job_ids = Job.createMultiple(store, nb_jobs)
110
def composeJobInsertionTuple(derived_series, parent_series,
111
sourcepackagename, job_id):
113
derived_series.distribution.id, derived_series.id,
114
DistributionJobType.DISTROSERIESDIFFERENCE, job_id,
115
DistributionJob.serializeMetadata(
116
{'sourcepackagename': sourcepackagename,
117
'parent_series': parent_series.id}))
118
format_string = "(%s)" % ", ".join(["%s"] * len(data))
119
return format_string % sqlvalues(*data)
122
composeJobInsertionTuple(
123
derived_series, parent_series, sourcepackagename, job_id)
124
for job_id, sourcepackagename in
125
zip(job_ids, sourcepackagenames)]
127
store = IStore(DistributionJob)
128
result = store.execute("""
129
INSERT INTO DistributionJob (
130
distribution, distroseries, job_type, job, json_data)
133
""" % ", ".join(job_contents))
134
return [job_id for job_id, in result]
137
81
def find_waiting_jobs(derived_series, sourcepackagename, parent_series=None):
138
82
"""Look for pending `DistroSeriesDifference` jobs on a package."""
139
83
# Look for identical pending jobs. This compares directly on
234
def massCreateForSeries(cls, derived_series, parent_series):
235
"""See `IDistroSeriesDifferenceJobSource`."""
236
if not getFeatureFlag(FEATURE_FLAG_ENABLE_MODULE):
238
create_multiple_jobs(derived_series, parent_series)
241
178
def getPendingJobsForDifferences(cls, derived_series,
242
179
distroseriesdifferences):
243
180
"""See `IDistroSeriesDifferenceJobSource`."""