Skip to content

Commit

Permalink
sort sync and publish history by an indexed key
Browse files Browse the repository at this point in the history
fixes pulp#1043
  • Loading branch information
asmacdo committed Jul 7, 2015
1 parent 0bce371 commit cb50793
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions server/pulp/server/managers/repo/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,10 @@ def publish_history(self, repo_id, distributor_id, limit=None, sort=constants.SO

# Retrieve the entries
cursor = RepoPublishResult.get_collection().find(search_params)
# Sort the results on the 'started' field. By default, descending order is used
cursor.sort('started', direction=constants.SORT_DIRECTION[sort])
# Sort the results by the ObjectId field, which will effectively sort based on the start
# time of the event. This way of sorting is preferred because for a sufficiently large data
# set, the sort field must be an indexed field.
cursor.sort('_id', direction=constants.SORT_DIRECTION[sort])
if limit is not None:
cursor.limit(limit)

Expand Down
6 changes: 4 additions & 2 deletions server/pulp/server/managers/repo/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,10 @@ def sync_history(self, repo_id, limit=None, sort=constants.SORT_DESCENDING, star

# Retrieve the entries
cursor = RepoSyncResult.get_collection().find(search_params)
# Sort the results on the 'started' field. By default, descending order is used
cursor.sort('started', direction=constants.SORT_DIRECTION[sort])
# Sort the results by the ObjectId field, which will effectively sort based on the start
# time of the event. This way of sorting is preferred because for a sufficiently large data
# set, the sort field must be an indexed field.
cursor.sort('_id', direction=constants.SORT_DIRECTION[sort])
if limit is not None:
cursor.limit(limit)

Expand Down

0 comments on commit cb50793

Please sign in to comment.