Return dossiers on api with stable order (#3921)
API : l'ordre des dossiers renvoyés dans les résultats paginés est maintenant stable
This commit is contained in:
commit
d050b9dc07
2 changed files with 2 additions and 1 deletions
|
@ -45,7 +45,7 @@ class API::V1::DossiersController < APIController
|
|||
render json: {}, status: :unauthorized
|
||||
end
|
||||
|
||||
@dossiers = @procedure.dossiers.state_not_brouillon
|
||||
@dossiers = @procedure.dossiers.state_not_brouillon.order_for_api
|
||||
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render json: {}, status: :not_found
|
||||
|
|
|
@ -51,6 +51,7 @@ class Dossier < ApplicationRecord
|
|||
scope :not_archived, -> { where(archived: false) }
|
||||
|
||||
scope :order_by_updated_at, -> (order = :desc) { order(updated_at: order) }
|
||||
scope :order_for_api, -> (order = :asc) { order(en_construction_at: order, created_at: order, id: order) }
|
||||
|
||||
scope :all_state, -> { not_archived.state_not_brouillon }
|
||||
scope :en_construction, -> { not_archived.state_en_construction }
|
||||
|
|
Loading…
Reference in a new issue