mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-11-25 19:26:09 +01:00
[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.
This commit is contained in:
parent
2d3b7ae939
commit
f7dac2c3d9
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue