Get report

This commit is contained in:
Nate Kelley 2025-08-04 15:25:22 -06:00
parent b3b759bd26
commit 1a955d786b
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
5 changed files with 6834 additions and 7 deletions

View File

@ -0,0 +1,2 @@
ALTER TYPE "public"."asset_type_enum" ADD VALUE 'report_file';--> statement-breakpoint
ALTER TABLE "asset_search" ALTER COLUMN "asset_type" SET DATA TYPE "public"."asset_type_enum" USING "asset_type"::"public"."asset_type_enum";

File diff suppressed because it is too large Load Diff

View File

@ -603,6 +603,13 @@
"when": 1754337436368,
"tag": "0085_create_report_table",
"breakpoints": true
},
{
"idx": 86,
"version": "7",
"when": 1754342648525,
"tag": "0086_report_table_enum_update",
"breakpoints": true
}
]
}

View File

@ -1,7 +1,13 @@
import { and, eq, isNull } from 'drizzle-orm';
import { z } from 'zod';
import { db } from '../../connection';
import { assetPermissions, collections, collectionsToAssets, reportFiles, users } from '../../schema';
import {
assetPermissions,
collections,
collectionsToAssets,
reportFiles,
users,
} from '../../schema';
import { getUserOrganizationId } from '../organizations';
export const GetReportInputSchema = z.object({
@ -90,11 +96,8 @@ export async function getReport(input: GetReportInput) {
)
);
const [reportDataResult, reportCollectionsResult, individualPermissionsResult] = await Promise.all([
reportDataQuery,
reportCollectionsQuery,
individualPermissionsQuery,
]);
const [reportDataResult, reportCollectionsResult, individualPermissionsResult] =
await Promise.all([reportDataQuery, reportCollectionsQuery, individualPermissionsQuery]);
const reportData = reportDataResult[0];
if (!reportData) {
@ -117,6 +120,7 @@ export async function getReport(input: GetReportInput) {
version_number: versionHistoryArray[versionHistoryArray.length - 1]?.version_number ?? 1,
version_history: versionHistoryArray,
collections: reportCollectionsResult,
individual_permissions: individualPermissionsResult,
};
return report;

View File

@ -470,7 +470,7 @@ export const assetSearch = pgTable(
{
id: uuid().defaultRandom().primaryKey().notNull(),
assetId: uuid('asset_id').notNull(),
assetType: text('asset_type').notNull(),
assetType: assetTypeEnum('asset_type').notNull(),
content: text().notNull(),
organizationId: uuid('organization_id').notNull(),
createdAt: timestamp('created_at', { withTimezone: true, mode: 'string' })