mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-03 13:44:33 -04:00
Add /unknowns route
This commit is contained in:
parent
29696c378a
commit
1476505262
@ -49,6 +49,10 @@ const extraFilters: FilterDef = {
|
|||||||
runtime: { column: entries.runtime, type: "float" },
|
runtime: { column: entries.runtime, type: "float" },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const unknownFilters: FilterDef = {
|
||||||
|
runtime: { column: entries.runtime, type: "float" },
|
||||||
|
};
|
||||||
|
|
||||||
const entrySort = Sort(
|
const entrySort = Sort(
|
||||||
[
|
[
|
||||||
"order",
|
"order",
|
||||||
@ -71,7 +75,7 @@ const extraSort = Sort(["slug", "name", "runtime", "createdAt"], {
|
|||||||
});
|
});
|
||||||
|
|
||||||
async function getEntries(
|
async function getEntries(
|
||||||
serie: string,
|
serie: string | null,
|
||||||
{
|
{
|
||||||
after,
|
after,
|
||||||
limit,
|
limit,
|
||||||
@ -95,7 +99,7 @@ async function getEntries(
|
|||||||
.where(
|
.where(
|
||||||
and(
|
and(
|
||||||
eq(shows.kind, "serie"),
|
eq(shows.kind, "serie"),
|
||||||
isUuid(serie) ? eq(shows.id, serie) : eq(shows.slug, serie),
|
isUuid(serie!) ? eq(shows.id, serie!) : eq(shows.slug, serie!),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.limit(1),
|
.limit(1),
|
||||||
@ -121,7 +125,7 @@ async function getEntries(
|
|||||||
...entryCol
|
...entryCol
|
||||||
} = getColumns(entries);
|
} = getColumns(entries);
|
||||||
return await db
|
return await db
|
||||||
.with(show)
|
.with(...(serie ? [show] : []))
|
||||||
.select({
|
.select({
|
||||||
...entryCol,
|
...entryCol,
|
||||||
...transCol,
|
...transCol,
|
||||||
@ -145,7 +149,7 @@ async function getEntries(
|
|||||||
.innerJoin(transQ, eq(entries.pk, transQ.pk))
|
.innerJoin(transQ, eq(entries.pk, transQ.pk))
|
||||||
.where(
|
.where(
|
||||||
and(
|
and(
|
||||||
eq(entries.showPk, show.pk),
|
serie ? eq(entries.showPk, show.pk) : undefined,
|
||||||
filter,
|
filter,
|
||||||
query ? sql`${transQ.name} %> ${query}::text` : undefined,
|
query ? sql`${transQ.name} %> ${query}::text` : undefined,
|
||||||
keysetPaginate({ table: entries, after, sort }),
|
keysetPaginate({ table: entries, after, sort }),
|
||||||
@ -270,6 +274,40 @@ export const entriesH = new Elysia()
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.get("/unknowns/:id", () => "hello" as unknown as UnknownEntry, {
|
.get(
|
||||||
response: { 200: "unknown_entry" },
|
"/unknowns",
|
||||||
});
|
async ({
|
||||||
|
query: { limit, after, query, sort, filter },
|
||||||
|
request: { url },
|
||||||
|
}) => {
|
||||||
|
const items = (await getEntries(null, {
|
||||||
|
limit,
|
||||||
|
after,
|
||||||
|
query,
|
||||||
|
sort: sort as any,
|
||||||
|
filter: and(eq(entries.kind, "unknown"), filter),
|
||||||
|
languages: ["extra"],
|
||||||
|
})) as UnknownEntry[];
|
||||||
|
|
||||||
|
return createPage(items, { url, sort, limit });
|
||||||
|
},
|
||||||
|
{
|
||||||
|
detail: { description: "Get unknown/unmatch videos." },
|
||||||
|
query: t.Object({
|
||||||
|
sort: extraSort,
|
||||||
|
filter: t.Optional(Filter({ def: unknownFilters })),
|
||||||
|
query: t.Optional(t.String({ description: desc.query })),
|
||||||
|
limit: t.Integer({
|
||||||
|
minimum: 1,
|
||||||
|
maximum: 250,
|
||||||
|
default: 50,
|
||||||
|
description: "Max page size.",
|
||||||
|
}),
|
||||||
|
after: t.Optional(t.String({ description: desc.after })),
|
||||||
|
}),
|
||||||
|
response: {
|
||||||
|
200: Page(UnknownEntry),
|
||||||
|
422: KError,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user