api: image download now filters only enabled devices
This commit is contained in:
parent
e5b148a933
commit
81031dc2aa
|
@ -44,7 +44,7 @@ func (api *API) DownloadSubredditImages(ctx context.Context, subreddit *models.S
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(devices) == 0 {
|
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)))
|
ctx, span := tracer.Start(ctx, "*API.DownloadSubredditImages", trace.WithAttributes(attribute.String("subreddit", subreddit.Name)))
|
||||||
|
|
|
@ -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())
|
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 {
|
if err != nil {
|
||||||
log.New(ctx).Err(err).Error("failed to query devices")
|
log.New(ctx).Err(err).Error("failed to query devices")
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue