From db1804b4a7d5ddf43e3b863d880833d4c919ea2a Mon Sep 17 00:00:00 2001 From: Jason Fischer Date: Thu, 20 Oct 2022 11:43:24 -0700 Subject: [PATCH] Fix incorrect wanted value in Radarr widget fixes #397 --- src/widgets/radarr/widget.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/widgets/radarr/widget.js b/src/widgets/radarr/widget.js index da3f2a6b9..d57f1b18d 100644 --- a/src/widgets/radarr/widget.js +++ b/src/widgets/radarr/widget.js @@ -1,6 +1,18 @@ import genericProxyHandler from "utils/proxy/handlers/generic"; import { jsonArrayFilter } from "utils/proxy/api-helpers"; +function isAvailable(item) { + // isAvailable means that a digital image exists + // E.g. it's available to stream or on DVD, etc + if (item.isAvailable === false) { + return false; + } + + // sizeOnDisk is how much of that digital image you currently have + // movieFile.size is how large the requested digital image is + return item.sizeOnDisk === item.movieFile?.size; +} + const widget = { api: "{url}/api/v3/{endpoint}?apikey={key}", proxyHandler: genericProxyHandler, @@ -9,8 +21,8 @@ const widget = { movie: { endpoint: "movie", map: (data) => ({ - wanted: jsonArrayFilter(data, (item) => item.isAvailable === false).length, - have: jsonArrayFilter(data, (item) => item.isAvailable === true).length, + wanted: jsonArrayFilter(data, (item) => !isAvailable(item)).length, + have: jsonArrayFilter(data, (item) => isAvailable(item)).length, }), }, "queue/status": {