Merge pull request '[BUG] Add early-return to loading items from SpecList' (#4582) from gusted/forgejo-early-return into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4582
Reviewed-by: Beowulf <beowulf@noreply.codeberg.org>
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
This commit is contained in:
Earl Warren 2024-07-20 07:40:24 +00:00
commit 622479ef7f

View file

@ -22,6 +22,10 @@ func (specs SpecList) GetScheduleIDs() []int64 {
} }
func (specs SpecList) LoadSchedules(ctx context.Context) error { func (specs SpecList) LoadSchedules(ctx context.Context) error {
if len(specs) == 0 {
return nil
}
scheduleIDs := specs.GetScheduleIDs() scheduleIDs := specs.GetScheduleIDs()
schedules, err := GetSchedulesMapByIDs(ctx, scheduleIDs) schedules, err := GetSchedulesMapByIDs(ctx, scheduleIDs)
if err != nil { if err != nil {
@ -50,6 +54,10 @@ func (specs SpecList) GetRepoIDs() []int64 {
} }
func (specs SpecList) LoadRepos(ctx context.Context) error { func (specs SpecList) LoadRepos(ctx context.Context) error {
if len(specs) == 0 {
return nil
}
repoIDs := specs.GetRepoIDs() repoIDs := specs.GetRepoIDs()
repos, err := repo_model.GetRepositoriesMapByIDs(ctx, repoIDs) repos, err := repo_model.GetRepositoriesMapByIDs(ctx, repoIDs)
if err != nil { if err != nil {