mirror of
https://github.com/Dictionarry-Hub/profilarr.git
synced 2026-01-31 14:50:50 +01:00
- Updated package.json to include Kysely and Deno Vite plugin dependencies. - Introduced new types for sorting in table component. - Refactored PCDCache to utilize Kysely for type-safe database queries. - Created new query files for quality profiles, including general information, languages, and list queries. - Removed outdated qualityProfiles.ts file and replaced it with modular query structure. - Updated routes to use new query functions for loading quality profile data. - Enhanced Vite configuration to include Deno plugin and improved watch settings.
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
/**
|
|
* Quality profile general queries
|
|
*/
|
|
|
|
import type { PCDCache } from '../../cache.ts';
|
|
import type { QualityProfileGeneral } from './types.ts';
|
|
|
|
/**
|
|
* Get general information for a single quality profile
|
|
*/
|
|
export async function general(cache: PCDCache, profileId: number): Promise<QualityProfileGeneral | null> {
|
|
const db = cache.kb;
|
|
|
|
// Get the quality profile
|
|
const profile = await db
|
|
.selectFrom('quality_profiles')
|
|
.select(['id', 'name', 'description'])
|
|
.where('id', '=', profileId)
|
|
.executeTakeFirst();
|
|
|
|
if (!profile) return null;
|
|
|
|
// Get tags for this profile
|
|
const tags = await db
|
|
.selectFrom('quality_profile_tags as qpt')
|
|
.innerJoin('tags as t', 't.id', 'qpt.tag_id')
|
|
.select(['t.id as tag_id', 't.name as tag_name', 't.created_at as tag_created_at'])
|
|
.where('qpt.quality_profile_id', '=', profileId)
|
|
.orderBy('t.name')
|
|
.execute();
|
|
|
|
return {
|
|
id: profile.id,
|
|
name: profile.name,
|
|
description: profile.description || '',
|
|
tags: tags.map((tag) => ({
|
|
id: tag.tag_id,
|
|
name: tag.tag_name,
|
|
created_at: tag.tag_created_at
|
|
}))
|
|
};
|
|
}
|