Refactoring part 2.4: Long func refactoring in graphql/resolvers (#1076)

* Split long functions and optimize code

* Addressing comments

* Remove unnecessary input param

---------

Co-authored-by: Konstantin Koval
This commit is contained in:
Kostiantyn
2024-10-11 12:31:49 +03:00
committed by GitHub
parent 7e0c38b5b4
commit dd90d476ad
10 changed files with 132 additions and 59 deletions

View File

@@ -49,7 +49,12 @@ func (r *mutationResolver) SetPeriodicScanInterval(ctx context.Context, interval
return 0, errors.New("interval must be 0 or above")
}
if err := db.Session(&gorm.Session{AllowGlobalUpdate: true}).Model(&models.SiteInfo{}).Update("periodic_scan_interval", interval).Error; err != nil {
if err := db.
Session(&gorm.Session{AllowGlobalUpdate: true}).
Model(&models.SiteInfo{}).
Update("periodic_scan_interval", interval).
Error; err != nil {
return 0, err
}
@@ -73,7 +78,12 @@ func (r *mutationResolver) SetScannerConcurrentWorkers(ctx context.Context, work
return 0, errors.New("multiple workers not supported for SQLite databases")
}
if err := db.Session(&gorm.Session{AllowGlobalUpdate: true}).Model(&models.SiteInfo{}).Update("concurrent_workers", workers).Error; err != nil {
if err := db.
Session(&gorm.Session{AllowGlobalUpdate: true}).
Model(&models.SiteInfo{}).
Update("concurrent_workers", workers).
Error; err != nil {
return 0, err
}