initial commit
Some checks failed
deploy / build-and-deploy (push) Failing after 21s

This commit is contained in:
2025-05-18 13:16:20 +02:00
commit 60f3f8a096
148 changed files with 17900 additions and 0 deletions

View File

@ -0,0 +1,54 @@
import { int, mysqlEnum, mysqlTable, text } from 'drizzle-orm/mysql-core';
import { strike } from './strike.ts';
import { admin } from './admin.ts';
import { report } from './report.ts';
import type { MySql2Database } from 'drizzle-orm/mysql2';
import { eq } from 'drizzle-orm';
type Database = MySql2Database<{ reportStatus: typeof reportStatus }>;
export const reportStatus = mysqlTable('report_status', {
status: mysqlEnum('status', ['open', 'closed']),
notice: text('notice'),
statement: text('statement'),
reportId: int('report_id')
.notNull()
.unique()
.references(() => report.id),
reviewerId: int('reviewer_id').references(() => admin.id),
strikeId: int('strike_id').references(() => strike.id)
});
export type GetReportStatusReq = {
reportId: number;
};
export type EditReportStatusReq = {
reportId: number;
status: 'open' | 'closed' | null;
notice: string | null;
statement: string | null;
strikeId: number | null;
};
export async function getReportStatus(db: Database, values: GetReportStatusReq) {
const rs = await db.query.reportStatus.findFirst({
where: eq(reportStatus.reportId, values.reportId)
});
return rs ?? null;
}
export async function editReportStatus(db: Database, values: EditReportStatusReq) {
return db
.insert(reportStatus)
.values(values)
.onDuplicateKeyUpdate({
set: {
status: values.status,
notice: values.notice,
statement: values.statement,
strikeId: values.strikeId
}
});
}