cron

package
v0.0.0-...-255846a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupOrphanOrgs

func CleanupOrphanOrgs(ctx context.Context, database *gorm.DB)

func CleanupUnmodifiedRepos

func CleanupUnmodifiedRepos(ctx context.Context, database *gorm.DB)

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 Register

func Register(manager *tasks.Manager, database *gorm.DB) error

Register adds the Forgejo organisation reconciliation task to the manager.

func RegisterRetention

func RegisterRetention(manager *tasks.Manager, database *gorm.DB, forgejoRequestDays int) error

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.

func RegisterStudentSync

func RegisterStudentSync(manager *tasks.Manager, database *gorm.DB) error

RegisterStudentSync wires the user-repo reconciliation task into the given manager. It is safe to call even when Forgejo is not configured, since the underlying task becomes a no-op in that case.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL