Adding ordered scope to Project-level Secure Files
What does this MR do and why?
This change adds an ordered scope to the SecureFile model to enable the API to return results in a consistent order.
Since this change introduces a query change, a database review is required. Below is a link to the query plan, and the raw queries old and new.
Something to note, projects are limited to 100 files per project, so the max rows this query should have to sort is 100.
QUESTION:
Since the query is now sorting on created_at I'm unsure if adding an index on created_at would provide any benefit. We're not filtering on a date range, nor are there cases where created_at would be nil. created_at is only being used to sort the result set.
Query Plan
https://explain.depesz.com/s/F6BN#html
Old Query
SELECT
    "ci_secure_files"."id",
    "ci_secure_files"."project_id",
    "ci_secure_files"."created_at",
    "ci_secure_files"."updated_at",
    "ci_secure_files"."file_store",
    "ci_secure_files"."name",
    "ci_secure_files"."file",
    "ci_secure_files"."checksum",
    "ci_secure_files"."key_data"
FROM
    "ci_secure_files"
WHERE
    "ci_secure_files"."project_id" = 21New Query
SELECT
    "ci_secure_files"."id",
    "ci_secure_files"."project_id",
    "ci_secure_files"."created_at",
    "ci_secure_files"."updated_at",
    "ci_secure_files"."file_store",
    "ci_secure_files"."name",
    "ci_secure_files"."file",
    "ci_secure_files"."checksum",
    "ci_secure_files"."key_data"
FROM
    "ci_secure_files"
WHERE
    "ci_secure_files"."project_id" = 21
ORDER BY
    "ci_secure_files"."created_at" DESCScreenshots or screen recordings
These are strongly recommended to assist reviewers and reduce the time to merge your change.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
- [-] I have evaluated the MR acceptance checklist for this MR.