From f7dac2c3d9b1caa7a7c60ae239fab0faf2f23681 Mon Sep 17 00:00:00 2001 From: Gusted Date: Sat, 20 Jul 2024 01:24:34 +0200 Subject: [PATCH] [BUG] Add early-return to loading items from `SpecList` - Add an early-return to `LoadSchedules` and `LoadRepos` of the `SpecList` type, @Beowulf noticed that useless queries were being run every 30 seconds. These stemmed from these two functions being run even if there were no scheduled actions. - No tests were added, because there is zero testing infrastructure or fixtures for the actions specifications models. I feel these are trivial enough to not require any tests. --- models/actions/schedule_spec_list.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/models/actions/schedule_spec_list.go b/models/actions/schedule_spec_list.go index f7dac72f8..4dc43f975 100644 --- a/models/actions/schedule_spec_list.go +++ b/models/actions/schedule_spec_list.go @@ -22,6 +22,10 @@ func (specs SpecList) GetScheduleIDs() []int64 { } func (specs SpecList) LoadSchedules(ctx context.Context) error { + if len(specs) == 0 { + return nil + } + scheduleIDs := specs.GetScheduleIDs() schedules, err := GetSchedulesMapByIDs(ctx, scheduleIDs) if err != nil { @@ -50,6 +54,10 @@ func (specs SpecList) GetRepoIDs() []int64 { } func (specs SpecList) LoadRepos(ctx context.Context) error { + if len(specs) == 0 { + return nil + } + repoIDs := specs.GetRepoIDs() repos, err := repo_model.GetRepositoriesMapByIDs(ctx, repoIDs) if err != nil {