Search code examples
gitlab

Gitlab sort multiple repositories by last commit date


In my internal gitlab site there are a lot of repositories and I want to find repositories which don't' have commits for so long .

In order to do this , I searched as last updated but it's not accurately reflect , looks like it's a bug . enter image description here


Solution

  • That could be similar to gitlab-org/gitlab-foss issue 56227:

    For example, I have a project testing-dev-project in a group.
    It displays that it was last updated 1 week ago.

    Using the inspector, the time is Dec 28, 2018. However, if I query the project with the API, I get the "last_activity_at":"2018-10-26T12:46:34.372-07:00".
    You can also check by going to the Project -> Activity or Project -> Settings -> Audit Events.

    But:

    This has likely always been the behavior - if a database migration touches something in a project then the updated_at timestamp is automatically updated by Rails.

    This is also mentioned in gitlab-org/gitlab issue 25862: "Show project creation dates when sorting group page on this attribute"

    For some reason, updated_at was updated fairly recently. I suspect a migration such as the one that encrypted the runners token column may have touched every project.
    As a result, the updated_at column may have been updated recently, and the projects appear to have been touched more recently than they should.

    Last updated being out of order due to the issues described in gitlab-org/gitlab-foss issue 27181

    That last issue is the most relevant, still opened, and finishes with:

    The discrepancy between the actual sort order and the displayed updated time is due to the fact that it displays the project's last_updated_date value, while sort is based on last_updated_at.

    It's not immediately obvious to me why these values are so different, it seems like they should be very close.
    I've submitted a MR that sets the list to display values from last_updated_at, though I'm not sure if a better long term solution would be to change the triggers that set last_updated_date and use that for sorting instead.

    This issue is moved to gitlab-org/gitlab issue 17017, which, in May 2024 (4 years late) is now closed/resolved, following MR 154256.

    • Checkout the branch
    • Visit one group that has subgroups/projects
    • Verify that sorting is working as expected 🎉

    See also GitLab 14.10 MR 82488: "Project list: order by real last update".