mirror of
https://github.com/go-gitea/gitea
synced 2025-02-24 07:21:26 +01:00
feat: Query the old action runs in DB (#26219)
As the Issue (#26219) mentioned, this is a database-level support to query the obsolete actions runs. I'll temporarily add a draft for further work.
This commit is contained in:
parent
581e52b3e7
commit
de5a83a685
@ -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).
|
||||
|
Loading…
x
Reference in New Issue
Block a user