Skip to content

Commit

Permalink
add count classroom publications request
Browse files Browse the repository at this point in the history
  • Loading branch information
SimNed committed Apr 23, 2024
1 parent c34f097 commit 25b3c27
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions server/controllers/statistics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ statisticsController.get({ path: '/contributions' }, async (_req, res) => {
);
});

statisticsController.get({ path: '/publications' }, async (_req, res) => {
res.sendJSON(await activityRepository.count({ where: { user: { type: UserType.TEACHER } } }));
});

statisticsController.get({ path: '/student-accounts' }, async (_req, res) => {
res.sendJSON(
await studentRepository
Expand Down
16 changes: 15 additions & 1 deletion src/api/statistics/statistics.get.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useQuery } from 'react-query';
import type { ContributionStats, StudentAccountsStats } from 'types/statistics.type';

import { axiosRequest } from 'src/utils/axiosRequest';
import type { ContributionStats, StudentAccountsStats } from 'types/statistics.type';

async function getContributions(): Promise<ContributionStats[]> {
return (
Expand All @@ -17,6 +17,20 @@ export const useGetContributions = () => {
return useQuery(['activities'], () => getContributions());
};

async function getPublications(): Promise<number> {
return (
await axiosRequest({
method: 'GET',
baseURL: '/api',
url: '/statistics/publications',
})
).data;
}

export const useGetPublications = () => {
return useQuery(['activities'], () => getPublications());
};

async function getStudentAccounts(): Promise<StudentAccountsStats> {
return (
await axiosRequest({
Expand Down

0 comments on commit 25b3c27

Please sign in to comment.