mirror of
https://github.com/BreizhHardware/Jellystat.git
synced 2026-01-18 16:27:20 +01:00
Fix for #231, missing day offset value
Added getLibraries api endpoint for upcoming fitrering freature on activity added LibraryId to getHistory endpoint to filter by Library
This commit is contained in:
@@ -149,6 +149,16 @@ router.get("/getconfig", async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
router.get("/getLibraries", async (req, res) => {
|
||||
try {
|
||||
const libraries = await db.query("SELECT * FROM jf_libraries").then((res) => res.rows);
|
||||
res.send(libraries);
|
||||
} catch (error) {
|
||||
res.status(503);
|
||||
res.send(error);
|
||||
}
|
||||
});
|
||||
|
||||
router.get("/getRecentlyAdded", async (req, res) => {
|
||||
try {
|
||||
const { libraryid, limit = 50, GroupResults = true } = req.query;
|
||||
@@ -940,11 +950,13 @@ router.delete("/libraryItems/purge", async (req, res) => {
|
||||
router.get("/getHistory", async (req, res) => {
|
||||
try {
|
||||
const { rows } = await db.query(`
|
||||
SELECT a.*, e."IndexNumber" "EpisodeNumber",e."ParentIndexNumber" "SeasonNumber"
|
||||
SELECT a.*, e."IndexNumber" "EpisodeNumber",e."ParentIndexNumber" "SeasonNumber" , i."ParentId"
|
||||
FROM jf_playback_activity a
|
||||
left join jf_library_episodes e
|
||||
on a."EpisodeId"=e."EpisodeId"
|
||||
and a."SeasonId"=e."SeasonId"
|
||||
left join jf_library_items i
|
||||
on i."Id"=a."NowPlayingItemId" or e."SeriesId"=i."Id"
|
||||
order by a."ActivityDateInserted" desc`);
|
||||
|
||||
const groupedResults = groupActivity(rows);
|
||||
|
||||
@@ -365,10 +365,11 @@ router.post("/getLibraryItemsPlayMethodStats", async (req, res) => {
|
||||
|
||||
router.post("/getPlaybackMethodStats", async (req, res) => {
|
||||
try {
|
||||
const { days } = req.body;
|
||||
let _days = days;
|
||||
if (days === undefined) {
|
||||
_days = 30;
|
||||
const { days = 30 } = req.body;
|
||||
|
||||
if (days < 0) {
|
||||
res.status(503);
|
||||
return res.send("Days cannot be less than 0");
|
||||
}
|
||||
|
||||
const { rows } = await db.query(
|
||||
@@ -376,8 +377,9 @@ router.post("/getPlaybackMethodStats", async (req, res) => {
|
||||
from jf_playback_activity a
|
||||
WHERE a."ActivityDateInserted" BETWEEN CURRENT_DATE - MAKE_INTERVAL(days => $1) AND NOW()
|
||||
Group by a."PlayMethod"
|
||||
ORDER BY (count(*)) DESC;
|
||||
`,
|
||||
[_days]
|
||||
[days - 1]
|
||||
);
|
||||
|
||||
res.send(rows);
|
||||
|
||||
Reference in New Issue
Block a user