Documentation
¶
Overview ¶
Package cron registers background jobs that maintain the forgejo_requests table. The current job deletes rows older than the configured retention window so the table does not grow unbounded.
Index ¶
- func CleanupOrphanOrgs(ctx context.Context, database *gorm.DB)
- func CleanupUnmodifiedRepos(ctx context.Context, database *gorm.DB)
- func Register(manager *tasks.Manager, database *gorm.DB) error
- func RegisterRetention(manager *tasks.Manager, database *gorm.DB, forgejoRequestDays int) error
- func RegisterStudentSync(manager *tasks.Manager, database *gorm.DB) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanupUnmodifiedRepos ¶
CleanupUnmodifiedRepos scans every course's Forgejo organisation and deletes orphaned per-student repositories, repos whose owner is no longer enrolled in the course, that are either empty (no commits at all) or an unmodified copy of the course's template repository. The standard course repos (configured via the course_repos setting) and every repo belonging to a currently enrolled student are always preserved.
"Orphaned" means: the repo's name matches a `users.preferred_username` of some user, and that user no longer has a `students` row for the course (i.e. the user left the course via the unassign-student endpoint, which hard-deletes the row).
"Unmodified copy of template" means: a repo whose default branch tip has the same commit SHA as the template's default branch tip. In other words, the student was provisioned a repo generated from the template but never committed anything of their own before leaving.
Repos that have at least one commit diverging from the template (i.e. the student pushed work) are left alone, even if the diff is small, because the work is the student's and is not safe to destroy silently.
The function is intended to be wired up as an on-demand admin task. It logs every deletion and a final summary so operators can see exactly what was removed.
func RegisterRetention ¶
RegisterRetention adds the forgejo_requests retention task to the manager.
This is registered independently of the Forgejo client configuration because the forgejo_requests table exists even when Forgejo itself is unconfigured (it just stays empty), and we want a single source of truth for the retention policy.
Types ¶
This section is empty.