Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/backend/db/db_setup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ CREATE TABLE reports (
report_id SERIAL PRIMARY KEY,
project_id INT NOT NULL REFERENCES projects(project_id) ON DELETE CASCADE,
object_url TEXT NOT NULL,
report_type TEXT NOT NULL DEFAULT 'technical' CHECK (report_type IN ('technical', 'narrative')),
date_created DATE NOT NULL DEFAULT CURRENT_DATE
);

Expand Down
1 change: 1 addition & 0 deletions apps/backend/lambdas/reports/db-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export interface BranchReports {
object_url: string;
project_id: number;
report_id: Generated<number>;
report_type: string;
}

export interface BranchUsers {
Expand Down
1 change: 1 addition & 0 deletions apps/backend/lambdas/reports/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const handler = async (event: any): Promise<APIGatewayProxyResult> => {
ok: true,
report_id: record.report_id,
object_url: record.object_url,
report_type: record.report_type,
});
}

Expand Down
6 changes: 6 additions & 0 deletions apps/backend/lambdas/reports/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ paths:
type: integer
object_url:
type: string
report_type:
type: string
enum: [technical, narrative]
date_created:
type: string
format: date
Expand Down Expand Up @@ -116,6 +119,9 @@ paths:
type: integer
object_url:
type: string
report_type:
type: string
enum: [technical, narrative]
'400':
description: Invalid input
'401':
Expand Down
8 changes: 5 additions & 3 deletions apps/backend/lambdas/reports/report-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,15 +337,17 @@ export async function uploadToS3(pdfBuffer: Buffer, projectId: number): Promise<
export async function saveReportRecord(
projectId: number,
objectUrl: string,
): Promise<{ report_id: number; object_url: string }> {
reportType: 'technical' | 'narrative' = 'technical',
): Promise<{ report_id: number; object_url: string; report_type: string }> {
const row = await db
.insertInto('branch.reports')
.values({
project_id: projectId,
object_url: objectUrl,
report_type: reportType,
})
.returning(['report_id', 'object_url'])
.returning(['report_id', 'object_url', 'report_type'])
.executeTakeFirstOrThrow();

return { report_id: row.report_id, object_url: row.object_url };
return { report_id: row.report_id, object_url: row.object_url, report_type: row.report_type };
}
Loading