api: image download now filters only enabled devices

This commit is contained in:
Tigor Hutasuhut 2024-05-06 13:50:22 +07:00
parent e5b148a933
commit 81031dc2aa
2 changed files with 2 additions and 2 deletions

View file

@ -44,7 +44,7 @@ func (api *API) DownloadSubredditImages(ctx context.Context, subreddit *models.S
}
if len(devices) == 0 {
return errs.Wrapw(ErrNoDevices, "downloading images requires at least one device configured").Code(http.StatusBadRequest)
return errs.Wrapw(ErrNoDevices, "downloading images requires at least one device configured and enabled").Code(http.StatusBadRequest)
}
ctx, span := tracer.Start(ctx, "*API.DownloadSubredditImages", trace.WithAttributes(attribute.String("subreddit", subreddit.Name)))

View file

@ -58,7 +58,7 @@ func (api *API) StartSubredditDownloadPubsub(messages <-chan *message.Message) {
log.New(ctx).Err(err).Error("failed to set schedule status", "subreddit", subreddit.Name, "status", ScheduleStatusDownloading.String())
}
devices, err := models.Devices.Query(ctx, api.db).All()
devices, err := models.Devices.Query(ctx, api.db, models.SelectWhere.Devices.Enable.EQ(1)).All()
if err != nil {
log.New(ctx).Err(err).Error("failed to query devices")
return