Background migration: update projects updated_at by greatest timestamp
What does this MR do and why?
A project list is displayed in various places in GitLab (e.g. dashboard or Explore projects
page). For each project in the list, it shows when it was last updated (e.g. "Updated 1 week ago"). This text is based on the maximum of three timestamps of a project: last_activity_at
, last_repository_updated_at
, and updated_at
. This is fine and makes sense.
However, there is a problem with sorting: You can sort the list by "Last updated" (or "Oldest updated"), but unfortunately this sorting option only considers the last_activity_at
timestamp. This causes that the project list doesn't seem sorted correctly for the user (see screenshots below).
- In !78572 (merged), the first step to solve this problem was done: The
updated_at
property now contains the actual timestamp of the last update (consideringlast_activity_at
andlast_repository_updated_at
as well). - The second step is done in this MR:
If you sort the list by "Last updated" (or "Oldest updated"), it will considerA background migration updatesupdated_at
instead oflast_activity_at
.projects.updated_at
by the greatest timestamp oflast_activity_at
,last_repository_updated_at
andupdated_at
. - In a follow-up MR: If you sort the list by "Last updated" (or "Oldest updated"), it will consider
updated_at
instead oflast_activity_at
.
Preceding approaches:
-
!75350 (closed): First attempt to solve the problem by adding an index using
GREATEST(updated_at, last_activity_at, last_repository_updated_at)
(closed due to datetime inconsistencies) - !77497 (closed): Second attempt to solve the problem by adding a separate column containing the actual greatest timestamp using a trigger (closed in favor of this MR as the solution is not ideal from a database point of view)
/cc @bufferoverflow
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.