mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Fix history percent calculation
This commit is contained in:
parent
09dd78b272
commit
d6d3540b16
@ -1,20 +1,9 @@
|
|||||||
import {
|
import { and, count, eq, exists, gt, isNotNull, ne, sql } from "drizzle-orm";
|
||||||
and,
|
|
||||||
count,
|
|
||||||
eq,
|
|
||||||
exists,
|
|
||||||
gt,
|
|
||||||
isNotNull,
|
|
||||||
ne,
|
|
||||||
not,
|
|
||||||
or,
|
|
||||||
sql,
|
|
||||||
} from "drizzle-orm";
|
|
||||||
import { alias } from "drizzle-orm/pg-core";
|
import { alias } from "drizzle-orm/pg-core";
|
||||||
import Elysia, { t } from "elysia";
|
import Elysia, { t } from "elysia";
|
||||||
import { auth, getUserInfo } from "~/auth";
|
import { auth, getUserInfo } from "~/auth";
|
||||||
import { db } from "~/db";
|
import { db } from "~/db";
|
||||||
import { entries, history, profiles, videos } from "~/db/schema";
|
import { entries, history, profiles, shows, videos } from "~/db/schema";
|
||||||
import { watchlist } from "~/db/schema/watchlist";
|
import { watchlist } from "~/db/schema/watchlist";
|
||||||
import { coalesce, values } from "~/db/utils";
|
import { coalesce, values } from "~/db/utils";
|
||||||
import { Entry } from "~/models/entry";
|
import { Entry } from "~/models/entry";
|
||||||
@ -244,6 +233,11 @@ export const historyH = new Elysia({ tags: ["profiles"] })
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const showKindQ = db
|
||||||
|
.select({ k: shows.kind })
|
||||||
|
.from(shows)
|
||||||
|
.where(eq(shows.pk, sql`excluded.show_pk`));
|
||||||
|
|
||||||
await db
|
await db
|
||||||
.insert(watchlist)
|
.insert(watchlist)
|
||||||
.select(
|
.select(
|
||||||
@ -302,7 +296,11 @@ export const historyH = new Elysia({ tags: ["profiles"] })
|
|||||||
else ${watchlist.status}
|
else ${watchlist.status}
|
||||||
end
|
end
|
||||||
`,
|
`,
|
||||||
seenCount: sql`${seenCountQ}`,
|
seenCount: sql`
|
||||||
|
case
|
||||||
|
when ${showKindQ} = 'movie' then excluded.seen_count
|
||||||
|
else ${seenCountQ}
|
||||||
|
end`,
|
||||||
nextEntry: sql`
|
nextEntry: sql`
|
||||||
case
|
case
|
||||||
when ${watchlist.status} = 'completed' then null
|
when ${watchlist.status} = 'completed' then null
|
||||||
|
Loading…
x
Reference in New Issue
Block a user