Skip to content

Commit

Permalink
feat: finished interface for task
Browse files Browse the repository at this point in the history
  • Loading branch information
Danie1T committed Oct 28, 2023
1 parent 57b79cd commit 426ddd8
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 101 deletions.
19 changes: 0 additions & 19 deletions backend/typescript/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -138,22 +138,3 @@ model notification_user {
recipient_id Int
seen Boolean @default(false)
}

model Task {
id Int @id @default(autoincrement())
category Category @relation(fields: [category_id], references: [id])
category_id Int
title String
status Statuses
description String
assignee Resident @relation(fields: [assignee_id], references: [id])
assignee_id Int
assigner Staff @relation(fields: [assigner_id], references: [id])
assigner_id Int
credit_value Float
start_date DateTime
end_date DateTime?
comments String
recurrence_frequency Recurrence_Frequency
warnings Warning[]
}
151 changes: 69 additions & 82 deletions backend/typescript/services/interfaces/taskService.ts
Original file line number Diff line number Diff line change
@@ -1,88 +1,75 @@
import {
CreateTaskDTO,
Role,
SignUpMethod,
UpdateTaskDTO,
TaskDTO,
} from "../../types"; // not sure lmao
type Status = "Pending Approval" | "Incomplete" | "Complete" | "Excused";

interface TaskService {
/**
* Get the task corresponding to the taskId
* @param id task id
* @returns a TaskDTO associated with the task id
* @throws Error if task retrieval fails
*/
getTaskById(id: string): Promise<TaskDTO>;
type TaskDTO = {
id: string;
categoryId: string;
title: string;
status: Status;
description: string;
assigneeId: string;
creditValue: string;
startDate: string;
endDate: string;
comments: string;
recurrenceFrequency: string;
warnings: string [];
}

/**
* Get all tasks belonging to a category
* @param categoryId category's id
* @returns a TaskDTO with category information
* @throws Error if task retrieval fails
*/
getTasksByCategoryId(categoryId: string): Promise<TaskDTO>;
/**
* Get all tasks assigned to a resident
* @param assigneeId assignee's id
* @returns a UserDTO with user's information
* @throws Error if task retrieval fails
*/
getTasksByAssigneeId(assigneeId: string): Promise<TaskDTO>;
interface TaskService {
/**
* Get the task corresponding to the taskId
* @param id task id
* @returns a TaskDTO associated with the task id
* @throws Error if task retrieval fails
*/
getTaskById(id: string): Promise<TaskDTO>;

/**
* Get all tasks assigned by a staff member
* @param assignerId assigner's id
* @returns a TaskDTO with user's information
* @throws Error if task retrieval fails
*/
getTasksByAssignerId(assignerId: string): Promise<TaskDTO>;
/**
* Get all tasks belonging to a category
* @param categoryId category's id
* @returns a TaskDTO with category information
* @throws Error if task retrieval fails
*/
getTasksByCategoryId(categoryId: string): Promise<TaskDTO>;

/**
* Get all tasks assigned to a resident
* @param assigneeId assignee's id
* @returns a TaskDTO with task's information
* @throws Error if task retrieval fails
*/
getTasksByAssigneeId(assigneeId: string): Promise<TaskDTO>;

/**
* Create a task
* @param task the user to be created
* @returns a TaskDTO with the created task's information
* @throws Error if task creation fails
*/
createTask(task: CreateTaskDTO): Promise<TaskDTO>;

/**
* Update a task.
* @param taskId task's id
* @param task the task to be updated
* @returns a TaskDTO with the updated task's information
* @throws Error if task update fails
*/
updateTaskById(taskId: string, task: UpdateTaskDTO): Promise<TaskDTO>;
/**
* Get all tasks assigned by a staff member
* @param assignerId assigner's id
* @returns a TaskDTO with task's information
* @throws Error if task retrieval fails
*/
getTasksByAssignerId(assignerId: string): Promise<TaskDTO>;

/**
* Delete a task by id
* @param taskId task's taskId
* @throws Error if task deletion fails
*/
deleteTaskById(taskId: string): Promise<void>;
}
/**
* Create a task
* @param task the user to be created
* @returns a TaskDTO with the created task's information
* @throws Error if task creation fails
*/
createTask(task: TaskDTO): Promise<TaskDTO>;

/**
* Update a task.
* @param taskId task's id
* @param task the task to be updated
* @returns a TaskDTO with the updated task's information
* @throws Error if task update fails
*/
updateTaskById(taskId: string, task: TaskDTO): Promise<TaskDTO>;




// Create, Edit, Complete, Delete, Get all

// model Task {
// id Int @id @default(autoincrement())
// category Category @relation(fields: [category_id], references: [id])
// category_id Int
// title String
// status Statuses
// description String
// assignee Resident @relation(fields: [assignee_id], references: [id])
// assignee_id Int
// assigner Staff @relation(fields: [assigner_id], references: [id])
// assigner_id Int
// credit_value Float
// start_date DateTime
// end_date DateTime?
// comments String
// recurrence_frequency Recurrence_Frequency
// warnings Warning[]
// }
/**
* Delete a task by id
* @param taskId task's taskId
* @returns a TaskDTO with the deleted task's information
* @throws Error if task deletion fails
*/
deleteTaskById(taskId: string): Promise<TaskDTO>;
}

0 comments on commit 426ddd8

Please sign in to comment.