Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/stats page #3105

Merged
merged 93 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
94aa3f0
#2829 stats page schema changes
wavehassman Sep 19, 2024
709218a
migration
wavehassman Sep 20, 2024
9c3fd20
stats route set up and page blank page exists now
martin0he Sep 25, 2024
7b57d78
#2773: added comments
martin0he Sep 25, 2024
ff96c58
Merge pull request #2854 from Northeastern-Electric-Racing/#2773-stat…
walker-sean Sep 28, 2024
1ad6b2d
schema changes
wavehassman Sep 28, 2024
1fa1d92
lowercase field names
wavehassman Oct 7, 2024
5b2660d
Merge pull request #2841 from Northeastern-Electric-Racing/#2829-stat…
walker-sean Oct 8, 2024
65457a8
add chart.js to stats page
wavehassman Oct 30, 2024
f3c63f3
#2775: Recommitting and updating dependencies
gcooper407 Nov 4, 2024
3785540
#2775: Updated yarn.lock to reflect newly updated dependencies
gcooper407 Nov 4, 2024
2a597ca
setup models, shared types, query args, transformers and init tests
martin0he Nov 6, 2024
7a64215
#2875: linting
martin0he Nov 6, 2024
8102b2c
#2875: linting again
martin0he Nov 6, 2024
98caef1
#2988 added files to make endpoints
wavehassman Nov 16, 2024
10a5de6
added export statements to controller nad services
wavehassman Nov 16, 2024
b334df2
took out json dependency
wavehassman Nov 16, 2024
6358c14
#2988-linting
wavehassman Nov 16, 2024
d4f839d
Merge pull request #2993 from Northeastern-Electric-Racing/#2988-endp…
Peyton-McKee Nov 20, 2024
7c9c36e
#2875 Dynamic SQL Gen
Peyton-McKee Nov 20, 2024
39e6d29
Merge branch 'feature/stats-page' into #2875-stats-page-create-graph-…
Peyton-McKee Nov 20, 2024
c81ef38
#2875 Merge Conflicts
Peyton-McKee Nov 20, 2024
9bc9450
#2875 Prettier
Peyton-McKee Nov 20, 2024
ab40f28
Merge pull request #2926 from Northeastern-Electric-Racing/#2875-stat…
Peyton-McKee Nov 20, 2024
a96c166
created `editGraph` in services
kb578432 Nov 24, 2024
ceb561a
#2775: Switched contained from div to a Box
gcooper407 Nov 24, 2024
6780882
created `editGraph` in controller
kb578432 Nov 24, 2024
4dda634
Merge pull request #2924 from Northeastern-Electric-Racing/#2775-bar-…
walker-sean Nov 29, 2024
a2c4a59
Merge branch 'develop' into feature/stats-page
Peyton-McKee Dec 5, 2024
d91f33a
Merge branch 'feature/stats-page' into #2879-Create-Edit-Graph-Endpoint
kb578432 Dec 5, 2024
3241f2e
service, control, and router code
cielbellerose Dec 5, 2024
930ce96
Merge branch 'feature/stats-page' into #2877-KinseyBellerose-getSingu…
cielbellerose Dec 5, 2024
e6d79c0
#2776: Completed pie chart component and added sample pie chart to st…
gcooper407 Dec 8, 2024
1ba752d
#2776: Added indication that sample components are a test
gcooper407 Dec 8, 2024
4b9782b
#3033 Create Graph Form
Peyton-McKee Dec 9, 2024
27ca389
Fix Build Issues
Peyton-McKee Dec 9, 2024
c63b0f8
#3033 Move Hook to Form
Peyton-McKee Dec 9, 2024
7c7923c
#3033 Remove Schema.txt file
Peyton-McKee Dec 9, 2024
0e1afe7
#3033 Correctly Generate Graph With All options
Peyton-McKee Dec 10, 2024
d69cf38
#3033 Prettier
Peyton-McKee Dec 10, 2024
1b3ce45
return issue fixed
cielbellerose Dec 10, 2024
d45363a
tests + added id to Graph interface
cielbellerose Dec 11, 2024
f958fea
route fixed + seed data for tests
cielbellerose Dec 11, 2024
c9e077f
#2877
cielbellerose Dec 11, 2024
ddde548
#2877 prettier and lint
cielbellerose Dec 11, 2024
9b86032
#2776: Updated statistics controller to remove return statements (not…
gcooper407 Dec 11, 2024
85ea74c
removed comment
cielbellerose Dec 12, 2024
64b0593
javadoc + exceptions
cielbellerose Dec 12, 2024
763947a
graph query conversion + fixed tests
cielbellerose Dec 13, 2024
d37565d
#2877 lint
cielbellerose Dec 13, 2024
bfcd9be
#2877 query parent key fix
cielbellerose Dec 13, 2024
a445ba3
#2776: Added description to test utils to resolve test checks failing
gcooper407 Dec 17, 2024
ac36ab2
#2776: Updated description to test utils to resolve test checks faili…
gcooper407 Dec 17, 2024
496471e
Merge pull request #3059 from Northeastern-Electric-Racing/2776-stats…
wavehassman Dec 17, 2024
ac3fffe
#2877 Adjust Graphing
Peyton-McKee Dec 17, 2024
0eddce7
Merge branch 'feature/stats-page' into #2877-KinseyBellerose-getSingu…
Peyton-McKee Dec 17, 2024
b2dce6f
#2877 Prettier Linting
Peyton-McKee Dec 17, 2024
dc8d9b6
Merge pull request #3062 from Northeastern-Electric-Racing/#2877-Kins…
Peyton-McKee Dec 17, 2024
96e638c
Merge branch 'feature/stats-page' into 3033-Get-Graph-Config
Peyton-McKee Dec 17, 2024
165c444
#3033 Adjust Graph Creation
Peyton-McKee Dec 18, 2024
09e1b1f
#3033 Prettier Fix Form View
Peyton-McKee Dec 18, 2024
43c16e6
#2879: unit tests
kb578432 Dec 18, 2024
d9db5a6
#3033 Allow Data to be filtered by time
Peyton-McKee Dec 18, 2024
9f105db
#2879: prettier
kb578432 Dec 18, 2024
8ad3ff3
#3033 Add Tests Hook Up Frontend
Peyton-McKee Dec 18, 2024
70dcfc3
Merge pull request #3061 from Northeastern-Electric-Racing/3033-Get-G…
Peyton-McKee Dec 18, 2024
a67a904
Raw Frontend (No Styling)
Peyton-McKee Dec 20, 2024
057fcfb
prettier
Peyton-McKee Dec 20, 2024
9d14a64
services,transformer,controller,routes functions + tests
staysgt Dec 18, 2024
1ea5fa9
2883: Updated controller, routes, services, transformer to work with …
staysgt Dec 19, 2024
8f3777a
2883-finishing testing + seed data
staysgt Dec 20, 2024
316faa7
#2883 fixing tests
staysgt Dec 21, 2024
bb46e51
Merge pull request #3085 from Northeastern-Electric-Racing/#2883-Crea…
Peyton-McKee Dec 21, 2024
ef9d16d
Merge pull request #3086 from Northeastern-Electric-Racing/stats-page…
Peyton-McKee Dec 22, 2024
5935531
Merge branch 'feature/stats-page' into #2879-Create-Edit-Graph-Endpoint
Peyton-McKee Dec 24, 2024
503a974
#2879 Merge Conflicts
Peyton-McKee Dec 24, 2024
9aeb019
#2879 Typo
Peyton-McKee Dec 24, 2024
cf976d2
Merge pull request #3073 from Northeastern-Electric-Racing/#2879-Crea…
Peyton-McKee Dec 24, 2024
6547401
#2774: Completed line graph component and added sample line graph to …
gcooper407 Dec 27, 2024
752f57c
Add Necessary Backend Endpoints for Funtioning Creation and Retrieval
Peyton-McKee Dec 27, 2024
2a148aa
#2774: Completed line graph component and added sample line graph to …
gcooper407 Dec 27, 2024
760ea49
Cleanup UI
Peyton-McKee Dec 27, 2024
97d1eb0
prettier
Peyton-McKee Dec 27, 2024
44686f7
Fix Frontend Test
Peyton-McKee Dec 27, 2024
36a15e4
Merge pull request #3102 from Northeastern-Electric-Racing/Stats-Clea…
Peyton-McKee Jan 2, 2025
6a4e37b
Merge branch 'develop' into feature/stats-page
Peyton-McKee Jan 3, 2025
5a398c0
Merge branch 'feature/stats-page' into 2774-stats-page-line-graph-com…
gcooper407 Jan 5, 2025
961543a
#2774: Updated line graph component according to Peyton's modificatio…
gcooper407 Jan 5, 2025
3e34a31
Merge branch '2774-stats-page-line-graph-component-3' into 2774-stats…
gcooper407 Jan 5, 2025
cbb2559
#2774: Reverted changes to the statistics page
gcooper407 Jan 6, 2025
af67283
Dont require title, add units
Peyton-McKee Jan 6, 2025
045ea9e
Merge pull request #3101 from Northeastern-Electric-Racing/2774-stats…
Peyton-McKee Jan 6, 2025
1a3e5eb
prettier
Peyton-McKee Jan 6, 2025
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
2 changes: 2 additions & 0 deletions src/backend/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import workPackageTemplatesRouter from './src/routes/work-package-templates.rout
import carsRouter from './src/routes/cars.routes';
import organizationRouter from './src/routes/organizations.routes';
import recruitmentRouter from './src/routes/recruitment.routes';
import statisticsRouter from './src/routes/statistics.routes';

const app = express();

Expand Down Expand Up @@ -68,6 +69,7 @@ app.use('/templates', workPackageTemplatesRouter);
app.use('/cars', carsRouter);
app.use('/organizations', organizationRouter);
app.use('/recruitment', recruitmentRouter);
app.use('/statistics', statisticsRouter);
app.use('/', (_req, res) => {
res.status(200).json('Welcome to FinishLine');
});
Expand Down
142 changes: 142 additions & 0 deletions src/backend/src/controllers/statistics.controllers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import { NextFunction, Request, Response } from 'express';
import StatisticsService from '../services/statistics.services';
import { Graph, GraphCollection } from 'shared';

export default class StatisticsController {
static async createGraph(req: Request, res: Response, next: NextFunction) {
try {
const {
startDate,
endDate,
title,
graphType,
graphDisplayType,
measure,
carIds,
graphCollectionId,
specialPermissions
} = req.body;

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

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

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

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);
}
}
}
25 changes: 25 additions & 0 deletions src/backend/src/prisma-query-args/statistics.query-args.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Prisma } from '@prisma/client';
import { getUserQueryArgs, getUserWithSettingsQueryArgs } from './user.query-args';

export type GraphQueryArgs = ReturnType<typeof getGraphQueryArgs>;
export type GraphCollectionQueryArgs = ReturnType<typeof getGraphCollectionQueryArgs>;

export const getGraphQueryArgs = (organizationId: string) =>
Prisma.validator<Prisma.GraphDefaultArgs>()({
include: {
organization: true,
userCreated: getUserWithSettingsQueryArgs(organizationId),
userDeleted: getUserQueryArgs(organizationId),
cars: true
}
});

export const getGraphCollectionQueryArgs = (organizationId: string) =>
Prisma.validator<Prisma.Graph_CollectionDefaultArgs>()({
include: {
graphs: getGraphQueryArgs(organizationId),
organization: true,
userCreated: getUserQueryArgs(organizationId),
userDeleted: getUserQueryArgs(organizationId)
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
-- CreateEnum
CREATE TYPE "Graph_Type" AS ENUM ('PROJECT_BUDGET_BY_PROJECT', 'PROJECT_BUDGET_BY_TEAM', 'PROJECT_BUDGET_BY_DIVISION', 'CHANGE_REQUESTS_BY_PROJECT', 'CHANGE_REQUESTS_BY_TEAM', 'CHANGE_REQUESTS_BY_DIVISION', 'REIMBURSEMENT_TOTAL_BY_PROJECT', 'REIMBURSEMENT_TOTAL_BY_TEAM', 'REIMBURSEMENT_TOTAL_BY_DIVISION');

-- CreateEnum
CREATE TYPE "Graph_Display_Type" AS ENUM ('PIE', 'BAR');

-- CreateEnum
CREATE TYPE "Measure" AS ENUM ('SUM', 'AVG');

-- CreateEnum
CREATE TYPE "Graph_Permission" AS ENUM ('EDIT_GRAPH', 'CREATE_GRAPH', 'VIEW_GRAPH', 'DELETE_GRAPH');

-- CreateEnum
CREATE TYPE "Graph_Collection_Permission" AS ENUM ('EDIT_GRAPH_COLLECTION', 'CREATE_GRAPH_COLLECTION', 'VIEW_GRAPH_COLLECTION', 'DELETE_GRAPH_COLLECTION');

-- CreateEnum
CREATE TYPE "Special_Permission" AS ENUM ('FINANCE_ONLY');

-- AlterTable
ALTER TABLE "Team_Type" ADD COLUMN "dateDeleted" TIMESTAMP(3),
ADD COLUMN "deletedById" TEXT;

-- AlterTable
ALTER TABLE "User" ADD COLUMN "additionalPermissions" TEXT[];

-- CreateTable
CREATE TABLE "Graph" (
"id" TEXT NOT NULL,
"startDate" TIMESTAMP(3),
"endDate" TIMESTAMP(3),
"title" TEXT NOT NULL,
"graphType" "Graph_Type" NOT NULL,
"displayGraphType" "Graph_Display_Type" NOT NULL,
"measure" "Measure" NOT NULL,
"dateDeleted" TIMESTAMP(3),
"dateCreated" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"specialPermissions" "Special_Permission"[],
"graphCollectionId" TEXT,
"userCreatedId" TEXT NOT NULL,
"userDeletedId" TEXT,
"organizationId" TEXT NOT NULL,

CONSTRAINT "Graph_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Graph_Collection" (
"id" TEXT NOT NULL,
"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,

CONSTRAINT "Graph_Collection_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "_graphCars" (
"A" TEXT NOT NULL,
"B" TEXT NOT NULL
);

-- CreateIndex
CREATE UNIQUE INDEX "_graphCars_AB_unique" ON "_graphCars"("A", "B");

-- CreateIndex
CREATE INDEX "_graphCars_B_index" ON "_graphCars"("B");

-- AddForeignKey
ALTER TABLE "Team_Type" ADD CONSTRAINT "Team_Type_deletedById_fkey" FOREIGN KEY ("deletedById") REFERENCES "User"("userId") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Graph" ADD CONSTRAINT "Graph_graphCollectionId_fkey" FOREIGN KEY ("graphCollectionId") REFERENCES "Graph_Collection"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Graph" ADD CONSTRAINT "Graph_userCreatedId_fkey" FOREIGN KEY ("userCreatedId") REFERENCES "User"("userId") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Graph" ADD CONSTRAINT "Graph_userDeletedId_fkey" FOREIGN KEY ("userDeletedId") REFERENCES "User"("userId") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Graph" ADD CONSTRAINT "Graph_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("organizationId") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Graph_Collection" ADD CONSTRAINT "Graph_Collection_userCreatedId_fkey" FOREIGN KEY ("userCreatedId") REFERENCES "User"("userId") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Graph_Collection" ADD CONSTRAINT "Graph_Collection_userDeletedId_fkey" FOREIGN KEY ("userDeletedId") REFERENCES "User"("userId") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Graph_Collection" ADD CONSTRAINT "Graph_Collection_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("organizationId") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "_graphCars" ADD CONSTRAINT "_graphCars_A_fkey" FOREIGN KEY ("A") REFERENCES "Car"("carId") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "_graphCars" ADD CONSTRAINT "_graphCars_B_fkey" FOREIGN KEY ("B") REFERENCES "Graph"("id") ON DELETE CASCADE ON UPDATE CASCADE;
Loading
Loading