1
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-01-02 01:17:43 +03:00
This commit is contained in:
Keine Ahnung 2024-12-30 15:50:17 +08:00 committed by GitHub
commit b46be6b7e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -377,6 +377,23 @@ func GetLatestRun(ctx context.Context, repoID int64) (*ActionRun, error) {
return run, nil
}
func GetRunsBeforeDate(ctx context.Context, repoID int64, beforeDate time.Time) ([]*ActionRun, error) {
var runs []*ActionRun
err := db.GetEngine(ctx).
Where("repo_id = ?", repoID).
And("created < ?", beforeDate).
Find(&runs)
if err != nil {
return nil, err
}
return runs, nil
}
func GetObsoleteRuns(ctx context.Context, repoID int64, days int) ([]*ActionRun, error) {
thresholdDate := time.Now().AddDate(0, 0, -days)
return GetRunsBeforeDate(ctx, repoID, thresholdDate)
}
func GetWorkflowLatestRun(ctx context.Context, repoID int64, workflowFile, branch, event string) (*ActionRun, error) {
var run ActionRun
q := db.GetEngine(ctx).Where("repo_id=?", repoID).