Skip to content

Commit

Permalink
Send collection ordered by updated_at ASC (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
lmatayoshi authored Dec 25, 2020
1 parent 1712d50 commit 68cf421
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/api/v1/api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def parameter_missing(error)
end

def filter(collection)
original_scope = collection.order(id: :asc)
original_scope = collection.order(updated_at: :asc)
if params[:updated_at_gth].present?
s = original_scope.where(
'date_trunc(\'milliseconds\', updated_at) > ?',
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/concerns/pagination.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
module Pagination
def render_paginated(collection, *_args)
paginated_collection = collection.page(page).per(per_page)
# greather_updated_at is just sent for legacy purposes.
# It's necessary for Collectors previous to 1.2.0:
# https://github.com/instedd/maap-collector/commit/04ce1ee301c2d44137ab754711afa6b5edddc19a
render json: {
items: serialized_collection(paginated_collection),
total_pages: paginated_collection.total_pages,
Expand Down

0 comments on commit 68cf421

Please sign in to comment.