mirror of
https://github.com/karl0ss/homepage.git
synced 2025-04-29 12:03:41 +01:00
use aggregate mapped data
to reduce the size of the API responses
This commit is contained in:
parent
9a77115a30
commit
28b2f79e5b
@ -29,13 +29,11 @@ export default function Lidarr({ service }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const have = albumsData.filter((album) => album.statistics.percentOfTracks === 100);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Widget>
|
<Widget>
|
||||||
<Block label={t("lidarr.wanted")} value={t("common.number", { value: wantedData.totalRecords })} />
|
<Block label={t("lidarr.wanted")} value={t("common.number", { value: wantedData.totalRecords })} />
|
||||||
<Block label={t("lidarr.queued")} value={t("common.number", { value: queueData.totalCount })} />
|
<Block label={t("lidarr.queued")} value={t("common.number", { value: queueData.totalCount })} />
|
||||||
<Block label={t("lidarr.albums")} value={t("common.number", { value: have.length })} />
|
<Block label={t("lidarr.albums")} value={t("common.number", { value: albumsData.have })} />
|
||||||
</Widget>
|
</Widget>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -28,14 +28,11 @@ export default function Radarr({ service }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const wanted = moviesData.filter((movie) => movie.isAvailable === false);
|
|
||||||
const have = moviesData.filter((movie) => movie.isAvailable === true);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Widget>
|
<Widget>
|
||||||
<Block label={t("radarr.wanted")} value={wanted.length} />
|
<Block label={t("radarr.wanted")} value={moviesData.wanted} />
|
||||||
<Block label={t("radarr.queued")} value={queuedData.totalCount} />
|
<Block label={t("radarr.queued")} value={queuedData.totalCount} />
|
||||||
<Block label={t("radarr.movies")} value={have.length} />
|
<Block label={t("radarr.movies")} value={moviesData.have} />
|
||||||
</Widget>
|
</Widget>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -29,13 +29,11 @@ export default function Readarr({ service }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const have = booksData.filter((book) => book.statistics.bookFileCount > 0);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Widget>
|
<Widget>
|
||||||
<Block label={t("readarr.wanted")} value={t("common.number", { value: wantedData.totalRecords })} />
|
<Block label={t("readarr.wanted")} value={t("common.number", { value: wantedData.totalRecords })} />
|
||||||
<Block label={t("readarr.queued")} value={t("common.number", { value: queueData.totalCount })} />
|
<Block label={t("readarr.queued")} value={t("common.number", { value: queueData.totalCount })} />
|
||||||
<Block label={t("readarr.books")} value={t("common.number", { value: have.length })} />
|
<Block label={t("readarr.books")} value={t("common.number", { value: booksData.have })} />
|
||||||
</Widget>
|
</Widget>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ export default function Sonarr({ service }) {
|
|||||||
<Widget>
|
<Widget>
|
||||||
<Block label={t("sonarr.wanted")} value={wantedData.totalRecords} />
|
<Block label={t("sonarr.wanted")} value={wantedData.totalRecords} />
|
||||||
<Block label={t("sonarr.queued")} value={queuedData.totalRecords} />
|
<Block label={t("sonarr.queued")} value={queuedData.totalRecords} />
|
||||||
<Block label={t("sonarr.series")} value={seriesData.length} />
|
<Block label={t("sonarr.series")} value={seriesData.total} />
|
||||||
</Widget>
|
</Widget>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -16,16 +16,63 @@ function jsonArrayMapper(data, map) {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function asJson(data) {
|
||||||
|
if (data?.length > 0) {
|
||||||
|
const json = JSON.parse(data.toString());
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
const serviceProxyHandlers = {
|
const serviceProxyHandlers = {
|
||||||
// uses query param auth
|
// uses query param auth
|
||||||
emby: genericProxyHandler,
|
emby: genericProxyHandler,
|
||||||
jellyfin: genericProxyHandler,
|
jellyfin: genericProxyHandler,
|
||||||
pihole: genericProxyHandler,
|
pihole: genericProxyHandler,
|
||||||
radarr: genericProxyHandler,
|
radarr: {
|
||||||
sonarr: genericProxyHandler,
|
proxy: genericProxyHandler,
|
||||||
lidarr: genericProxyHandler,
|
maps: {
|
||||||
readarr: genericProxyHandler,
|
movie: (data) => ({
|
||||||
bazarr: genericProxyHandler,
|
wanted: jsonArrayMapper(data, (item) => item.isAvailable === false).length,
|
||||||
|
have: jsonArrayMapper(data, (item) => item.isAvailable === true).length,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
sonarr: {
|
||||||
|
proxy: genericProxyHandler,
|
||||||
|
maps: {
|
||||||
|
series: (data) => ({
|
||||||
|
total: asJson(data.toString()).length,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
lidarr: {
|
||||||
|
proxy: genericProxyHandler,
|
||||||
|
maps: {
|
||||||
|
album: (data) => ({
|
||||||
|
have: jsonArrayMapper(data, (item) => item.statistics.percentOfTracks === 100).length,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
readarr: {
|
||||||
|
proxy: genericProxyHandler,
|
||||||
|
maps: {
|
||||||
|
book: (data) => ({
|
||||||
|
have: jsonArrayMapper(data, (item) => item.statistics.bookFileCount > 0).length,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
bazarr: {
|
||||||
|
proxy: genericProxyHandler,
|
||||||
|
maps: {
|
||||||
|
movies: (data) => ({
|
||||||
|
total: asJson(data.toString()).total,
|
||||||
|
}),
|
||||||
|
episodes: (data) => ({
|
||||||
|
total: asJson(data.toString()).total,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
speedtest: genericProxyHandler,
|
speedtest: genericProxyHandler,
|
||||||
tautulli: genericProxyHandler,
|
tautulli: genericProxyHandler,
|
||||||
traefik: genericProxyHandler,
|
traefik: genericProxyHandler,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user