Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 1,217 Bytes
98b0aa6 17aecfb 98b0aa6 17aecfb b34e9b1 98b0aa6 b34e9b1 17aecfb b1a4d81 b34e9b1 17aecfb 98b0aa6 17aecfb 98b0aa6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
import { error, json, type RequestEvent } from '@sveltejs/kit';
import prisma from '$lib/prisma';
/** @type {import('./$types').RequestHandler} */
// TODO
// run hooks to update each model by repo using hugging face api.
// refer to bulk-create-models +server.ts for example
export async function GET(request : RequestEvent) {
const page = parseInt(request.url.searchParams.get('page') || '0')
const filter = request.url.searchParams.get('filter') || 'hotest'
const search = request.url.searchParams.get('search') || ''
const cards = await prisma.model.findMany({
where: {
isPublic: true,
OR: [
{ title: { contains: search } },
{ repo: { contains: search } },
]
},
orderBy: {
...(filter === 'hotest' ? { downloads: 'desc' } : { likes: 'desc' })
},
skip: 20 * page,
take: 20,
})
const total_reposId = await prisma.model.count({
where: {
isPublic: true,
OR: [
{ title: { contains: search } },
{ repo: { contains: search } },
]
},
})
const hasError = false
if (hasError) {
return error(500, 'Internal Server Error')
}
return json({
cards,
total_items: total_reposId
})
}
|