From a01598c0b4ad3deaf55249d21b147ffcc43d6d74 Mon Sep 17 00:00:00 2001 From: Karl Hudgell Date: Wed, 7 Jun 2023 08:48:01 +0100 Subject: [PATCH 1/2] linting fixes --- src/widgets/jdrssdownloader/proxy.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/widgets/jdrssdownloader/proxy.js b/src/widgets/jdrssdownloader/proxy.js index 99452692..9b98c0a1 100644 --- a/src/widgets/jdrssdownloader/proxy.js +++ b/src/widgets/jdrssdownloader/proxy.js @@ -65,7 +65,7 @@ export default async function JDRssProxyHandler(req, res) { if (status !== 200) { return res.status(status).json({ error: { message: "HTTP error communicating with WGeasy API", data: Buffer.from(apiData).toString() } }); } - let showCount; + let showCount = 0; showCount = apiData.length; // Calculate the number of items in the retry cache @@ -73,7 +73,7 @@ export default async function JDRssProxyHandler(req, res) { if (status !== 200) { return res.status(status).json({ error: { message: "HTTP error communicating with WGeasy API", data: Buffer.from(apiData).toString() } }); } - let retryCache; + let retryCache = 0; retryCache = apiData.length; // Calculate the number of items in the feed cache @@ -81,17 +81,16 @@ export default async function JDRssProxyHandler(req, res) { if (status !== 200) { return res.status(status).json({ error: { message: "HTTP error communicating with WGeasy API", data: Buffer.from(apiData).toString() } }); } - let feedCache; + let feedCache = 0; feedCache = apiData.length; const data = { - showCount:showCount, - retryCache:retryCache, - feedCache:feedCache + showCount, + retryCache, + feedCache }; return res.status(status).send(data); } - From 9ae891dad7d95c6cdeb261e4d61b8d525a5be3f1 Mon Sep 17 00:00:00 2001 From: Karl Hudgell Date: Wed, 7 Jun 2023 08:52:22 +0100 Subject: [PATCH 2/2] new endpoint --- src/widgets/jdrssdownloader/proxy.js | 31 ++++++---------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/src/widgets/jdrssdownloader/proxy.js b/src/widgets/jdrssdownloader/proxy.js index 9b98c0a1..c301b447 100644 --- a/src/widgets/jdrssdownloader/proxy.js +++ b/src/widgets/jdrssdownloader/proxy.js @@ -59,35 +59,16 @@ export default async function JDRssProxyHandler(req, res) { } logger.debug("Getting data from JDRss API"); - // Calculate the number of Tracked Shows - let [status, apiData] = await fetchDataFromJDRss('shows', widget); + // Get data from JDRss stats API + const [status, apiData] = await fetchDataFromJDRss('stats', widget); if (status !== 200) { - return res.status(status).json({ error: { message: "HTTP error communicating with WGeasy API", data: Buffer.from(apiData).toString() } }); + return res.status(status).json({ error: { message: "HTTP error communicating with JDRss API", data: Buffer.from(apiData).toString() } }); } - let showCount = 0; - showCount = apiData.length; - - // Calculate the number of items in the retry cache - [status, apiData] = await fetchDataFromJDRss('retryCache', widget); - if (status !== 200) { - return res.status(status).json({ error: { message: "HTTP error communicating with WGeasy API", data: Buffer.from(apiData).toString() } }); - } - let retryCache = 0; - retryCache = apiData.length; - - // Calculate the number of items in the feed cache - [status, apiData] = await fetchDataFromJDRss('feedCache', widget); - if (status !== 200) { - return res.status(status).json({ error: { message: "HTTP error communicating with WGeasy API", data: Buffer.from(apiData).toString() } }); - } - let feedCache = 0; - feedCache = apiData.length; - const data = { - showCount, - retryCache, - feedCache + showCount:apiData.ShowList , + retryCache:apiData.RetryCache, + feedCache: apiData.FeedCache };