From 81031dc2aa220b8bbdf8bad9366ce5de7b8f2308 Mon Sep 17 00:00:00 2001 From: Tigor Hutasuhut Date: Mon, 6 May 2024 13:50:22 +0700 Subject: [PATCH] api: image download now filters only enabled devices --- api/download_subreddit_images.go | 2 +- api/pubsub_download.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/download_subreddit_images.go b/api/download_subreddit_images.go index 30556b3..f4c2a8b 100644 --- a/api/download_subreddit_images.go +++ b/api/download_subreddit_images.go @@ -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))) diff --git a/api/pubsub_download.go b/api/pubsub_download.go index d10970a..8fe78d0 100644 --- a/api/pubsub_download.go +++ b/api/pubsub_download.go @@ -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