From d9c2c3027a2094c94bd637e79d39fd3624dc6b98 Mon Sep 17 00:00:00 2001 From: basant-gautam Date: Sat, 10 Oct 2026 12:22:52 +0530 Subject: [PATCH] feat(database): add batch-wise and branch-wise student count reports --- src/Modules/Database/reports.js | 18 +++++ .../reports/BatchWiseStudentCountReport.jsx | 70 ++++++++++++++++++ .../reports/BranchWiseStudentCountReport.jsx | 71 +++++++++++++++++++ src/routes/academicRoutes/index.jsx | 2 + 4 files changed, 161 insertions(+) create mode 100644 src/Modules/Database/reports/BatchWiseStudentCountReport.jsx create mode 100644 src/Modules/Database/reports/BranchWiseStudentCountReport.jsx diff --git a/src/Modules/Database/reports.js b/src/Modules/Database/reports.js index 15d56fd09..27072b15e 100644 --- a/src/Modules/Database/reports.js +++ b/src/Modules/Database/reports.js @@ -6,6 +6,9 @@ import SwayamRegistrationsReport from "./reports/SwayamRegistrationsReport"; import SemesterRegistrationsReport from "./reports/SemesterRegistrationsReport"; import CreditsEarnedReport from "./reports/CreditsEarnedReport"; +import BatchWiseStudentCountReport from "./reports/BatchWiseStudentCountReport"; +import BranchWiseStudentCountReport from "./reports/BranchWiseStudentCountReport"; + // One entry per report. Adding a report means adding an entry here; the list // page and the report page both read from this. export const DATABASE_REPORTS = [ @@ -60,6 +63,21 @@ export const DATABASE_REPORTS = [ filters: "Batch", Component: CreditsEarnedReport, }, + { + id: "batch-wise-student-count", + title: "Batch-wise student count", + summary: "Male, female, and total candidate count for batches 2020 to 2026", + filters: "None", + Component: BatchWiseStudentCountReport, + }, + { + id: "branch-wise-student-count", + title: "Branch-wise student count", + summary: + "Male, female, and total candidate count per discipline for batches 2020 to 2026", + filters: "None", + Component: BranchWiseStudentCountReport, + }, ]; export const findReport = (id) => diff --git a/src/Modules/Database/reports/BatchWiseStudentCountReport.jsx b/src/Modules/Database/reports/BatchWiseStudentCountReport.jsx new file mode 100644 index 000000000..462b91fe5 --- /dev/null +++ b/src/Modules/Database/reports/BatchWiseStudentCountReport.jsx @@ -0,0 +1,70 @@ +import { useState, useEffect } from "react"; + +import { Button, Group, Stack, Text } from "@mantine/core"; +import { showNotification } from "@mantine/notifications"; +import { IconSearch } from "@tabler/icons-react"; +import axios from "axios"; +import { databaseBatchWiseStudentCountRoute } from "../../../routes/academicRoutes"; +import ReportTable from "../ReportTable"; + +const COLUMNS = [ + { key: "batch", label: "Batch" }, + { key: "male", label: "Male Candidates" }, + { key: "female", label: "Female Candidates" }, + { key: "total", label: "Grand Total" }, +]; + +export default function BatchWiseStudentCountReport() { + const [result, setResult] = useState(null); + const [loading, setLoading] = useState(false); + + const run = async () => { + setLoading(true); + try { + const token = localStorage.getItem("authToken"); + const { data } = await axios.get(databaseBatchWiseStudentCountRoute, { + headers: token ? { Authorization: `Token ${token}` } : {}, + }); + setResult(data); + } catch (error) { + showNotification({ + title: "Error", + message: error.response?.data?.detail || "Could not load the counts.", + color: "red", + }); + } finally { + setLoading(false); + } + }; + + useEffect(() => { + run(); + }, []); + + return ( + + + + + + {result ? ( + + ) : ( + + Fetching data... + + )} + + ); +} diff --git a/src/Modules/Database/reports/BranchWiseStudentCountReport.jsx b/src/Modules/Database/reports/BranchWiseStudentCountReport.jsx new file mode 100644 index 000000000..c2c5f07e4 --- /dev/null +++ b/src/Modules/Database/reports/BranchWiseStudentCountReport.jsx @@ -0,0 +1,71 @@ +import { useState, useEffect } from "react"; + +import { Button, Group, Stack, Text } from "@mantine/core"; +import { showNotification } from "@mantine/notifications"; +import { IconSearch } from "@tabler/icons-react"; +import axios from "axios"; +import { databaseBranchWiseStudentCountRoute } from "../../../routes/academicRoutes"; +import ReportTable from "../ReportTable"; + +const COLUMNS = [ + { key: "batch", label: "Batch" }, + { key: "branch", label: "Branch / Discipline" }, + { key: "male", label: "Male Candidates" }, + { key: "female", label: "Female Candidates" }, + { key: "total", label: "Total Candidates" }, +]; + +export default function BranchWiseStudentCountReport() { + const [result, setResult] = useState(null); + const [loading, setLoading] = useState(false); + + const run = async () => { + setLoading(true); + try { + const token = localStorage.getItem("authToken"); + const { data } = await axios.get(databaseBranchWiseStudentCountRoute, { + headers: token ? { Authorization: `Token ${token}` } : {}, + }); + setResult(data); + } catch (error) { + showNotification({ + title: "Error", + message: error.response?.data?.detail || "Could not load the counts.", + color: "red", + }); + } finally { + setLoading(false); + } + }; + + useEffect(() => { + run(); + }, []); + + return ( + + + + + + {result ? ( + + ) : ( + + Fetching data... + + )} + + ); +} diff --git a/src/routes/academicRoutes/index.jsx b/src/routes/academicRoutes/index.jsx index cb73c8c86..1a0e1b001 100644 --- a/src/routes/academicRoutes/index.jsx +++ b/src/routes/academicRoutes/index.jsx @@ -94,6 +94,8 @@ export const databaseCourseRegistrationCountsRoute = `${host}/aims/api/database/ export const databaseSwayamRegistrationsRoute = `${host}/aims/api/database/swayam-registrations/`; export const databaseSemesterRegistrationsRoute = `${host}/aims/api/database/semester-registrations/`; export const databaseCreditsEarnedRoute = `${host}/aims/api/database/credits-earned/`; +export const databaseBatchWiseStudentCountRoute = `${host}/aims/api/database/batch-wise-student-count/`; +export const databaseBranchWiseStudentCountRoute = `${host}/aims/api/database/branch-wise-student-count/`; export const academicProceduresFaculty = `${host}/academic-procedures/api/fac/academic_procedures_faculty`; export const getAllCourses = `${host}/academic-procedures/api/acad/get_all_courses`; export const generateprereport = `${host}/aims/api/generate_preregistration_report/`;