本文整理汇总了Python中lp.services.database.interfaces.IStore.order_by方法的典型用法代码示例。如果您正苦于以下问题:Python IStore.order_by方法的具体用法?Python IStore.order_by怎么用?Python IStore.order_by使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lp.services.database.interfaces.IStore
的用法示例。
在下文中一共展示了IStore.order_by方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getBuildsForArchive
# 需要导入模块: from lp.services.database.interfaces import IStore [as 别名]
# 或者: from lp.services.database.interfaces.IStore import order_by [as 别名]
def getBuildsForArchive(self, archive, status=None):
"""See `IBuildFarmJobSet`."""
extra_exprs = []
if status is not None:
extra_exprs.append(BuildFarmJob.status == status)
result_set = IStore(BuildFarmJob).find(
BuildFarmJob, BuildFarmJob.archive == archive, *extra_exprs)
# When we have a set of builds that may include pending or
# superseded builds, we order by -date_created (as we won't
# always have a date_finished). Otherwise we can order by
# -date_finished.
unfinished_states = [
BuildStatus.NEEDSBUILD,
BuildStatus.BUILDING,
BuildStatus.UPLOADING,
BuildStatus.SUPERSEDED,
]
if status is None or status in unfinished_states:
result_set.order_by(
Desc(BuildFarmJob.date_created), BuildFarmJob.id)
else:
result_set.order_by(
Desc(BuildFarmJob.date_finished), BuildFarmJob.id)
return result_set
示例2: getDiffsToReleases
# 需要导入模块: from lp.services.database.interfaces import IStore [as 别名]
# 或者: from lp.services.database.interfaces.IStore import order_by [as 别名]
def getDiffsToReleases(self, sprs, preload_for_display=False):
"""See `IPackageDiffSet`."""
from lp.registry.model.distribution import Distribution
from lp.soyuz.model.archive import Archive
from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
if len(sprs) == 0:
return EmptyResultSet()
spr_ids = [spr.id for spr in sprs]
result = IStore(PackageDiff).find(
PackageDiff, PackageDiff.to_sourceID.is_in(spr_ids))
result.order_by(PackageDiff.to_sourceID,
Desc(PackageDiff.date_requested))
def preload_hook(rows):
lfas = load(LibraryFileAlias, (pd.diff_contentID for pd in rows))
load(LibraryFileContent, (lfa.contentID for lfa in lfas))
sprs = load(
SourcePackageRelease,
itertools.chain.from_iterable(
(pd.from_sourceID, pd.to_sourceID) for pd in rows))
archives = load(Archive, (spr.upload_archiveID for spr in sprs))
load(Distribution, (a.distributionID for a in archives))
if preload_for_display:
return DecoratedResultSet(result, pre_iter_hook=preload_hook)
else:
return result
示例3: all_package_names
# 需要导入模块: from lp.services.database.interfaces import IStore [as 别名]
# 或者: from lp.services.database.interfaces.IStore import order_by [as 别名]
def all_package_names(self):
"""See `IHWDriverSet`."""
# XXX Abel Deuring 2009-06-19 The clause package_name != None
# can be removed once bug #306265 is fixed.
result = IStore(HWDriverPackageName).find(HWDriverPackageName, HWDriverPackageName.package_name != None)
result.order_by(HWDriverPackageName.package_name)
return result
示例4: getComments
# 需要导入模块: from lp.services.database.interfaces import IStore [as 别名]
# 或者: from lp.services.database.interfaces.IStore import order_by [as 别名]
def getComments(self):
"""See `IDistroSeriesDifference`."""
DSDComment = DistroSeriesDifferenceComment
comments = IStore(DSDComment).find(
DistroSeriesDifferenceComment,
DSDComment.distro_series_difference == self)
return comments.order_by(Desc(DSDComment.id))
示例5: test_retrieveDatabaseAncestry
# 需要导入模块: from lp.services.database.interfaces import IStore [as 别名]
# 或者: from lp.services.database.interfaces.IStore import order_by [as 别名]
def test_retrieveDatabaseAncestry(self):
# retrieveDatabaseAncestry should set db_ancestry and db_history to
# Launchpad's current understanding of the branch state.
# db_branch_revision_map should map Bazaar revision_ids to
# BranchRevision.ids.
# Use the sampledata for this test, so we do not have to rely on
# BzrSync to fill the database. That would cause a circular
# dependency, as the test setup would depend on
# retrieveDatabaseAncestry.
branch = getUtility(IBranchLookup).getByUniqueName("~name12/+junk/junk.contrib")
branch_revisions = IStore(BranchRevision).find(BranchRevision, BranchRevision.branch == branch)
sampledata = list(branch_revisions.order_by(BranchRevision.sequence))
expected_ancestry = set(branch_revision.revision.revision_id for branch_revision in sampledata)
expected_history = [
branch_revision.revision.revision_id
for branch_revision in sampledata
if branch_revision.sequence is not None
]
self.create_branch_and_tree(db_branch=branch)
bzrsync = self.makeBzrSync(branch)
db_ancestry, db_history = bzrsync.retrieveDatabaseAncestry()
self.assertEqual(expected_ancestry, set(db_ancestry))
self.assertEqual(expected_history, list(db_history))
示例6: _update
# 需要导入模块: from lp.services.database.interfaces import IStore [as 别名]
# 或者: from lp.services.database.interfaces.IStore import order_by [as 别名]
def _update(cls, distroseries, binarypackagename, archive, log):
"""Update the package cache for a given IBinaryPackageName
'log' is required, it should be a logger object able to print
DEBUG level messages.
'ztm' is the current trasaction manager used for partial commits
(in full batches of 100 elements)
"""
# get the set of published binarypackagereleases
bprs = IStore(BinaryPackageRelease).find(
BinaryPackageRelease,
BinaryPackageRelease.id ==
BinaryPackagePublishingHistory.binarypackagereleaseID,
BinaryPackagePublishingHistory.binarypackagename ==
binarypackagename,
BinaryPackagePublishingHistory.distroarchseriesID ==
DistroArchSeries.id,
DistroArchSeries.distroseries == distroseries,
BinaryPackagePublishingHistory.archive == archive,
BinaryPackagePublishingHistory.dateremoved == None)
bprs = bprs.order_by(Desc(BinaryPackageRelease.datecreated))
bprs = bprs.config(distinct=True)
if bprs.count() == 0:
log.debug("No binary releases found.")
return
# find or create the cache entry
cache = cls.selectOne("""
distroseries = %s AND
archive = %s AND
binarypackagename = %s
""" % sqlvalues(distroseries, archive, binarypackagename))
if cache is None:
log.debug("Creating new binary cache entry.")
cache = cls(
archive=archive,
distroseries=distroseries,
binarypackagename=binarypackagename)
# make sure the cached name, summary and description are correct
cache.name = binarypackagename.name
cache.summary = bprs[0].summary
cache.description = bprs[0].description
# get the sets of binary package summaries, descriptions. there is
# likely only one, but just in case...
summaries = set()
descriptions = set()
for bpr in bprs:
log.debug("Considering binary version %s" % bpr.version)
summaries.add(bpr.summary)
descriptions.add(bpr.description)
# and update the caches
cache.summaries = ' '.join(sorted(summaries))
cache.descriptions = ' '.join(sorted(descriptions))
示例7: getBinariesForOverrides
# 需要导入模块: from lp.services.database.interfaces import IStore [as 别名]
# 或者: from lp.services.database.interfaces.IStore import order_by [as 别名]
def getBinariesForOverrides(self, distroseries, pocket):
"""Fetch override information about all published binaries.
The override information consists of tuples with 'binaryname',
'component', 'section', 'architecture' and 'priority' strings,
'binpackageformat' enum, 'phased_update_percentage' integer, in this
order.
:param distroseries: target `IDistroSeries`
:param pocket: target `PackagePublishingPocket`
:return: a `ResultSet` with the binary override information tuples
"""
origins = (
BinaryPackagePublishingHistory,
Join(Component,
Component.id == BinaryPackagePublishingHistory.componentID),
Join(Section,
Section.id == BinaryPackagePublishingHistory.sectionID),
Join(BinaryPackageRelease,
BinaryPackageRelease.id ==
BinaryPackagePublishingHistory.binarypackagereleaseID),
Join(BinaryPackageName,
BinaryPackageName.id ==
BinaryPackageRelease.binarypackagenameID),
Join(DistroArchSeries,
DistroArchSeries.id ==
BinaryPackagePublishingHistory.distroarchseriesID),
)
architectures_ids = [arch.id for arch in distroseries.architectures]
if len(architectures_ids) == 0:
return EmptyResultSet()
conditions = [
BinaryPackagePublishingHistory.archive == self.publisher.archive,
BinaryPackagePublishingHistory.distroarchseriesID.is_in(
architectures_ids),
BinaryPackagePublishingHistory.pocket == pocket,
BinaryPackagePublishingHistory.status ==
PackagePublishingStatus.PUBLISHED,
]
if not self.publisher.archive.publish_debug_symbols:
conditions.append(
BinaryPackageRelease.binpackageformat
!= BinaryPackageFormat.DDEB)
result_set = IStore(BinaryPackageName).using(*origins).find(
(BinaryPackageName.name, Component.name, Section.name,
DistroArchSeries.architecturetag,
BinaryPackagePublishingHistory.priority,
BinaryPackageRelease.binpackageformat,
BinaryPackagePublishingHistory.phased_update_percentage),
*conditions)
return result_set.order_by(Desc(BinaryPackagePublishingHistory.id))
示例8: getBuildsBySourcePackageRelease
# 需要导入模块: from lp.services.database.interfaces import IStore [as 别名]
# 或者: from lp.services.database.interfaces.IStore import order_by [as 别名]
def getBuildsBySourcePackageRelease(self, sourcepackagerelease_ids,
buildstate=None):
"""See `IBinaryPackageBuildSet`."""
if (sourcepackagerelease_ids is None or
len(sourcepackagerelease_ids) == 0):
return []
query = [
BinaryPackageBuild.source_package_release_id.is_in(
sourcepackagerelease_ids),
BinaryPackageBuild.is_distro_archive,
]
if buildstate is not None:
query.append(BinaryPackageBuild.status == buildstate)
resultset = IStore(BinaryPackageBuild).find(BinaryPackageBuild, *query)
resultset.order_by(
Desc(BinaryPackageBuild.date_created), BinaryPackageBuild.id)
return resultset
示例9: getPendingJobsForTargetSeries
# 需要导入模块: from lp.services.database.interfaces import IStore [as 别名]
# 或者: from lp.services.database.interfaces.IStore import order_by [as 别名]
def getPendingJobsForTargetSeries(cls, target_series):
"""Get upcoming jobs for `target_series`, ordered by age."""
raw_jobs = IStore(PackageCopyJob).find(
PackageCopyJob,
Job.id == PackageCopyJob.job_id,
PackageCopyJob.job_type == cls.class_job_type,
PackageCopyJob.target_distroseries == target_series,
Job._status.is_in(Job.PENDING_STATUSES),
)
raw_jobs = raw_jobs.order_by(PackageCopyJob.id)
return DecoratedResultSet(raw_jobs, cls)
示例10: getActiveJobs
# 需要导入模块: from lp.services.database.interfaces import IStore [as 别名]
# 或者: from lp.services.database.interfaces.IStore import order_by [as 别名]
def getActiveJobs(cls, target_archive):
"""See `IPlainPackageCopyJobSource`."""
jobs = IStore(PackageCopyJob).find(
PackageCopyJob,
PackageCopyJob.job_type == cls.class_job_type,
PackageCopyJob.target_archive == target_archive,
Job.id == PackageCopyJob.job_id,
Job._status == JobStatus.WAITING,
)
jobs = jobs.order_by(PackageCopyJob.id)
return DecoratedResultSet(jobs, cls)
示例11: iterReady
# 需要导入模块: from lp.services.database.interfaces import IStore [as 别名]
# 或者: from lp.services.database.interfaces.IStore import order_by [as 别名]
def iterReady(cls):
"""Iterate through all ready PackageCopyJobs.
Even though it's slower, we repeat the query each time in order that
very long queues of mass syncs can be pre-empted by other jobs.
"""
seen = set()
while True:
jobs = IStore(PackageCopyJob).find(
PackageCopyJob,
PackageCopyJob.job_type == cls.class_job_type,
PackageCopyJob.job == Job.id,
Job.id.is_in(Job.ready_jobs),
Not(Job.id.is_in(seen)),
)
jobs.order_by(PackageCopyJob.copy_policy)
job = jobs.first()
if job is None:
break
seen.add(job.job_id)
yield cls(job)
示例12: _getPublishingHistoryQuery
# 需要导入模块: from lp.services.database.interfaces import IStore [as 别名]
# 或者: from lp.services.database.interfaces.IStore import order_by [as 别名]
def _getPublishingHistoryQuery(self, status=None):
conditions = [
SourcePackagePublishingHistory.archiveID.is_in(
self.distribution.all_distro_archive_ids),
SourcePackagePublishingHistory.distroseriesID == DistroSeries.id,
DistroSeries.distribution == self.distribution,
SourcePackagePublishingHistory.sourcepackagename ==
self.sourcepackagename,
SourcePackageRelease.id ==
SourcePackagePublishingHistory.sourcepackagereleaseID,
]
if status is not None:
conditions.append(SourcePackagePublishingHistory.status == status)
res = IStore(SourcePackagePublishingHistory).find(
(SourcePackagePublishingHistory, SourcePackageRelease),
*conditions)
res.order_by(
Desc(SourcePackagePublishingHistory.datecreated),
Desc(SourcePackagePublishingHistory.id))
return DecoratedResultSet(res, operator.itemgetter(0))
示例13: search
# 需要导入模块: from lp.services.database.interfaces import IStore [as 别名]
# 或者: from lp.services.database.interfaces.IStore import order_by [as 别名]
def search(self, query, vocab_filter=None):
"""Search for web bug trackers."""
query = ensure_unicode(query).lower()
results = IStore(self._table).find(
self._table, And(
self._filter,
BugTracker.active == True,
Or(
CONTAINSSTRING(BugTracker.name, query),
CONTAINSSTRING(BugTracker.title, query),
CONTAINSSTRING(BugTracker.summary, query),
CONTAINSSTRING(BugTracker.baseurl, query))))
results = results.order_by(self._order_by)
return results
示例14: getBinaryFiles
# 需要导入模块: from lp.services.database.interfaces import IStore [as 别名]
# 或者: from lp.services.database.interfaces.IStore import order_by [as 别名]
def getBinaryFiles(self, distroseries, pocket):
"""Fetch publishing information about all published binary files.
The publishing information consists of tuples with 'sourcename',
'filename', 'component' and 'architecture' strings, in this order.
:param distroseries: target `IDistroSeries`
:param pocket: target `PackagePublishingPocket`
:return: a `ResultSet` with the binary files information tuples.
"""
columns = (
SourcePackageName.name,
LibraryFileAlias.filename,
Component.name,
Concatenate(u"binary-", DistroArchSeries.architecturetag),
)
join_conditions = [
BinaryPackageRelease.id ==
BinaryPackagePublishingHistory.binarypackagereleaseID,
BinaryPackageFile.binarypackagereleaseID ==
BinaryPackagePublishingHistory.binarypackagereleaseID,
BinaryPackageBuild.id == BinaryPackageRelease.buildID,
SourcePackageRelease.id ==
BinaryPackageBuild.source_package_release_id,
SourcePackageName.id == SourcePackageRelease.sourcepackagenameID,
LibraryFileAlias.id == BinaryPackageFile.libraryfileID,
DistroArchSeries.id ==
BinaryPackagePublishingHistory.distroarchseriesID,
Component.id == BinaryPackagePublishingHistory.componentID,
]
select_conditions = [
BinaryPackagePublishingHistory.dateremoved == None,
DistroArchSeries.distroseriesID == distroseries.id,
BinaryPackagePublishingHistory.archive == self.publisher.archive,
BinaryPackagePublishingHistory.pocket == pocket,
BinaryPackagePublishingHistory.status ==
PackagePublishingStatus.PUBLISHED,
]
if not self.publisher.archive.publish_debug_symbols:
select_conditions.append(
BinaryPackageRelease.binpackageformat
!= BinaryPackageFormat.DDEB)
result_set = IStore(SourcePackageRelease).find(
columns, *(join_conditions + select_conditions))
return result_set.order_by(
BinaryPackagePublishingHistory.id, BinaryPackageFile.id)
示例15: findPublishedSPPHs
# 需要导入模块: from lp.services.database.interfaces import IStore [as 别名]
# 或者: from lp.services.database.interfaces.IStore import order_by [as 别名]
def findPublishedSPPHs(self, distroseries, pocket, package_name):
"""Find currently published source publications for given package."""
SPPH = SourcePackagePublishingHistory
SPR = SourcePackageRelease
query = IStore(SourcePackagePublishingHistory).find(
SPPH,
join_spph_spr(),
join_spph_spn(),
SourcePackageName.name == package_name,
self._composeActiveSourcePubsCondition(distroseries, pocket))
# Sort by descending version (SPR.version has type debversion in
# the database, so this should be a real proper comparison) so
# that _sortPackage will have slightly less work to do later.
return query.order_by(Desc(SPR.version), Desc(SPPH.datecreated))