Skip to content

Commit

Permalink
Merge branch '2774-stats-page-line-graph-component-3' into 2774-stats…
Browse files Browse the repository at this point in the history
…-page-line-graph-component-2
  • Loading branch information
gcooper407 committed Jan 5, 2025
2 parents 6547401 + 961543a commit 3e34a31
Show file tree
Hide file tree
Showing 67 changed files with 2,006 additions and 344 deletions.
97 changes: 94 additions & 3 deletions src/backend/src/controllers/statistics.controllers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NextFunction, Request, Response } from 'express';
import StatisticsService from '../services/statistics.services';
import { Graph } from 'shared';
import { Graph, GraphCollection } from 'shared';

export default class StatisticsController {
static async createGraph(req: Request, res: Response, next: NextFunction) {
Expand Down Expand Up @@ -39,13 +39,104 @@ export default class StatisticsController {

static async getSingleGraph(req: Request, res: Response, next: NextFunction) {
try {
const { id } = req.params;
const { graphId } = req.params;

const requestedGraph = await StatisticsService.getSingleGraph(id, req.currentUser, req.organization);
const requestedGraph = await StatisticsService.getSingleGraph(graphId, req.currentUser, req.organization);

res.status(200).json(requestedGraph);
} catch (error: unknown) {
next(error);
}
}

static async getAllGraphCollections(req: Request, res: Response, next: NextFunction) {
try {
const graphCollections = await StatisticsService.getAllGraphCollections(req.currentUser, req.organization);
res.status(200).json(graphCollections);
} catch (error: unknown) {
next(error);
}
}

static async editGraph(req: Request, res: Response, next: NextFunction) {
try {
const {
startDate,
endDate,
title,
graphType,
measure,
graphDisplayType,
graphCollectionId,
carIds,
specialPermissions
} = req.body;
const { graphId } = req.params;

const updatedGraph = await StatisticsService.editGraph(
req.currentUser,
graphId,
title,
graphType,
measure,
graphDisplayType,
req.organization,
carIds,
specialPermissions,
startDate ? new Date(startDate) : undefined,
endDate ? new Date(endDate) : undefined,
graphCollectionId
);

res.status(200).json(updatedGraph);
} catch (error: unknown) {
next(error);
}
}

static async createGraphCollection(req: Request, res: Response, next: NextFunction) {
try {
const { title, specialPermissions } = req.body;
const graphCollection: GraphCollection = await StatisticsService.createGraphCollection(
req.currentUser,
title,
specialPermissions,
req.organization
);
res.status(200).json(graphCollection);
} catch (error: unknown) {
next(error);
}
}

static async editGraphCollection(req: Request, res: Response, next: NextFunction) {
try {
const { title, specialPermissions } = req.body;
const { graphCollectionId } = req.params;
const graphCollection: GraphCollection = await StatisticsService.editGraphCollection(
req.currentUser,
graphCollectionId,
title,
specialPermissions,
req.organization
);
res.status(200).json(graphCollection);
} catch (error: unknown) {
next(error);
}
}

static async getSingleGraphCollection(req: Request, res: Response, next: NextFunction) {
try {
const { graphCollectionId } = req.params;
const graphCollection: GraphCollection = await StatisticsService.getSingleGraphCollection(
req.currentUser,
graphCollectionId,
req.organization
);
res.status(200).json(graphCollection);
} catch (error: unknown) {
next(error);
}
}
}
4 changes: 2 additions & 2 deletions src/backend/src/controllers/tasks.controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ export default class TasksController {
wbsNum,
title,
notes,
new Date(deadline),
priority,
status,
assignees,
req.organization
req.organization,
deadline ? new Date(deadline) : undefined
);

res.status(200).json(task);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Task" ALTER COLUMN "deadline" DROP NOT NULL;
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ CREATE TABLE "Graph_Collection" (
"title" TEXT NOT NULL,
"dateDeleted" TIMESTAMP(3),
"viewPermissions" "Special_Permission"[],
"dateCreated" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"userCreatedId" TEXT NOT NULL,
"userDeletedId" TEXT,
"organizationId" TEXT NOT NULL,
Expand Down
3 changes: 2 additions & 1 deletion src/backend/src/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ model Task {
taskId String @id @default(uuid())
title String
notes String
deadline DateTime
deadline DateTime?
assignees User[] @relation(name: "assignedTo")
priority Task_Priority
status Task_Status
Expand Down Expand Up @@ -1011,6 +1011,7 @@ model Graph_Collection {
dateDeleted DateTime?
viewPermissions Special_Permission[]
graphs Graph[]
dateCreated DateTime @default(now())
userCreatedId String
userCreated User @relation(fields: [userCreatedId], references: [userId], name: "graphCollectionsCreator")
Expand Down
Loading

0 comments on commit 3e34a31

Please sign in to comment.