# frozen_string_literal: true
#=Controller for the Revisions API.
class RevisionsController < ApplicationController
  respond_to :json
  DEFAULT_REVISION_LIMIT = 10

  # Returns revisions for a single user within the scope of a single course.
  def index
    user = User.find(params[:user_id])
    course = Course.find(params[:course_id])

    @revisions = course.revisions.where(user_id: user.id)
                       .order('revisions.created_at DESC')
                       .eager_load(:article)
                       .limit(params[:limit] || DEFAULT_REVISION_LIMIT)
  end
end

# frozen_string_literal: true
#=Controller for the Revisions API.
class RevisionsController < ApplicationController
  respond_to :json
  DEFAULT_REVISION_LIMIT = 10

  # Returns revisions for a single user within the scope of a single course.
  def index
    user = User.find(params[:user_id])
    course = Course.find(params[:course_id])

    @revisions = course.revisions.where(user_id: user.id)
                       .order('revisions.date DESC')
                       .eager_load(:article)
                       .limit(params[:limit] || DEFAULT_REVISION_LIMIT)
  end
end

Order recent user revisions by date, not created_at
Order recent user revisions by date, not created_at

Often a batch of newly imported edits will have the same 'created_at' timestamp, and actual most recent edits will not be included within the results.
