mirror of
https://github.com/RayLabsHQ/gitea-mirror.git
synced 2026-05-08 20:58:16 -05:00
[GH-ISSUE #225] [feat. request] sorting repository table #471
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kapdon on GitHub (Mar 14, 2026).
Original GitHub issue: https://github.com/RayLabsHQ/gitea-mirror/issues/225
Originally assigned to: @arunavo4 on GitHub.
I want to add sorting feature to the repository table, mainly so I can show recently imported repository on top.
my first pass on this has a few gaps that need to be addressed from a architecture perspective.
When repositories are imported from GitHub, the createdAt field is populated from GitHub's repo.created_at timestamp (src/lib/github.ts:290,351,495). This means sorting by "date added" isn't possible with the current schema.
we'd be sorting by when the repo was created on GitHub, which isn't useful for understanding when a user added it to the mirror system.
The mirrorJobs table tracks import events (jobType: "import"), so technically we could look up when a repo was first imported by querying the earliest job record. However, this would require a join or subquery per repository at render time, which is expensive — especially for users with hundreds of repos. This approach also breaks down if job history is cleaned up by the cleanup service.
Proposal:
Add a dedicated importedAt timestamp column to the repositories table in src/lib/db/schema.ts
Backfill strategy for existing data:
It won't be perfectly accurate (it'll reflect the GitHub creation date), but it's a reasonable approximation for existing data.
let me know your thoughts
@arunavo4 commented on GitHub (Mar 15, 2026):
Implemented in #226.
What we changed
repositories.imported_at(NOT NULL, defaultunixepoch()).(user_id, imported_at)for fast user-scoped sorting./api/github/repositoriesdefault ordering toimportedAt DESC, then name.importedAtin repository response typing.How imported time is determined
importedAt = nowin GitHub import/sync flows.mirror_jobs.timestampwherestatus='imported'.repository_idwhen present.repository_idis missing.repositories.created_at.Sorting outcome