[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.
(cherry picked from commit f7dac2c3d9
)
This commit is contained in:
parent
0ed8aa276d
commit
358be0a8dd
1 changed files with 8 additions and 0 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue