-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added transcodeOutcome job * Added assets page * feat: Added table for assets * Added filtering to assets page
- Loading branch information
Showing
39 changed files
with
1,028 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { db } from "../db"; | ||
|
||
export async function getGroups() { | ||
return await db.selectFrom("groups").select(["id", "name"]).execute(); | ||
} | ||
|
||
export async function getOrCreateGroup(name: string) { | ||
let group = await db | ||
.selectFrom("groups") | ||
.select(["id", "name"]) | ||
.where("name", "=", name) | ||
.executeTakeFirst(); | ||
if (!group) { | ||
group = await db | ||
.insertInto("groups") | ||
.values({ name }) | ||
.returning(["id", "name"]) | ||
.executeTakeFirstOrThrow(); | ||
} | ||
return group; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { db } from "../db"; | ||
import type { PlayableInsert } from "../db/types"; | ||
|
||
export async function createPlayable(fields: PlayableInsert) { | ||
return await db | ||
.insertInto("playables") | ||
.values(fields) | ||
.executeTakeFirstOrThrow(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { Elysia, t } from "elysia"; | ||
import { authUser } from "./token"; | ||
import { getAssets, getAssetsCount } from "../repositories/assets"; | ||
import { getGroups } from "../repositories/groups"; | ||
import { AssetSchema } from "../types"; | ||
|
||
export const assets = new Elysia() | ||
.use(authUser) | ||
.get( | ||
"/assets", | ||
async ({ query }) => { | ||
const assets = await getAssets(query); | ||
|
||
const count = await getAssetsCount(); | ||
const totalPages = Math.ceil(count / query.perPage); | ||
|
||
return { | ||
page: query.page, | ||
totalPages, | ||
assets, | ||
}; | ||
}, | ||
{ | ||
detail: { | ||
summary: "Get all assets", | ||
tags: ["Assets"], | ||
}, | ||
|
||
query: t.Object({ | ||
page: t.Number(), | ||
perPage: t.Number(), | ||
orderBy: t.String(), | ||
direction: t.String(), | ||
}), | ||
response: { | ||
200: t.Object({ | ||
page: t.Number(), | ||
totalPages: t.Number(), | ||
assets: t.Array(AssetSchema), | ||
}), | ||
}, | ||
}, | ||
) | ||
.get( | ||
"/groups", | ||
async () => { | ||
return await getGroups(); | ||
}, | ||
{ | ||
detail: { | ||
summary: "Get all groups", | ||
tags: ["Assets"], | ||
}, | ||
}, | ||
); |
Oops, something went wrong.