From b6b3f52bfd7c6d017b83155d939e48cace1b2a83 Mon Sep 17 00:00:00 2001 From: "Grayson, Matthew" Date: Fri, 29 Mar 2024 11:11:04 -0500 Subject: [PATCH] Add category number; clean up imports in assessments.ts. --- backend/src/api/assessments.ts | 14 +++++--------- backend/src/models/category.ts | 3 +++ backend/src/tasks/rscsyncdb.ts | 0 backend/test/assessments.test.ts | 0 4 files changed, 8 insertions(+), 9 deletions(-) create mode 100644 backend/src/tasks/rscsyncdb.ts create mode 100644 backend/test/assessments.test.ts diff --git a/backend/src/api/assessments.ts b/backend/src/api/assessments.ts index a929cc57..56e1f582 100644 --- a/backend/src/api/assessments.ts +++ b/backend/src/api/assessments.ts @@ -1,10 +1,6 @@ import { validateBody, wrapHandler, NotFound, Unauthorized } from './helpers'; -import { connectToDatabase } from '../models'; -import { Assessment } from '../models/assessment'; +import { Assessment, connectToDatabase } from '../models'; import { isUUID } from 'class-validator'; -import { Response } from '../models/response'; -import { Question } from '../models/question'; -import { Category } from '../models/category'; /** * @swagger @@ -20,7 +16,7 @@ export const createAssessment = wrapHandler(async (event) => { await connectToDatabase(); - const assessment = await Assessment.create(body); + const assessment = Assessment.create(body); await Assessment.save(assessment); return { @@ -34,11 +30,11 @@ export const createAssessment = wrapHandler(async (event) => { * * /assessments: * get: - * description: Lists all assessments for the logged in user. + * description: Lists all assessments for the logged-in user. * tags: * - Assessments */ -export const listAssessments = wrapHandler(async (event) => { +export const list = wrapHandler(async (event) => { const userId = event.requestContext.authorizer!.id; if (!userId) { @@ -70,7 +66,7 @@ export const listAssessments = wrapHandler(async (event) => { * tags: * - Assessments */ -export const getAssessment = wrapHandler(async (event) => { +export const get = wrapHandler(async (event) => { const assessmentId = event.pathParameters?.id; if (!assessmentId || !isUUID(assessmentId)) { diff --git a/backend/src/models/category.ts b/backend/src/models/category.ts index 2bbbf542..17af649a 100644 --- a/backend/src/models/category.ts +++ b/backend/src/models/category.ts @@ -15,6 +15,9 @@ export class Category extends BaseEntity { @Column() name: string; + @Column({ nullable: true }) + number: number; + @Column({ nullable: true }) shortName: string; diff --git a/backend/src/tasks/rscsyncdb.ts b/backend/src/tasks/rscsyncdb.ts new file mode 100644 index 00000000..e69de29b diff --git a/backend/test/assessments.test.ts b/backend/test/assessments.test.ts new file mode 100644 index 00000000..e69de29b