Skip to content

Commit

Permalink
Merge pull request #986 from parlemonde/ft/VIL-575
Browse files Browse the repository at this point in the history
add Api call, clean statistics api call, change type type in teamComm…
  • Loading branch information
SimNed authored Sep 10, 2024
2 parents b21bcb3 + 36faf3b commit f3f484a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 52 deletions.
2 changes: 0 additions & 2 deletions server/controllers/analytic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,6 @@ analyticController.router.post(
AppDataSource.getRepository(User).createQueryBuilder('user').select('user.firstlogin').where({ id: data.userId }).getRawOne(),
]);

console.log('User Phase in analytics', userPhase);

if (sessionCount === 0 && data.event === 'pageview' && data.params?.isInitial) {
const session = new AnalyticSession();
session.id = data.sessionId;
Expand Down
49 changes: 0 additions & 49 deletions src/api/statistics/statistics.get.ts
Original file line number Diff line number Diff line change
@@ -1,52 +1,3 @@
// import { useQuery } from 'react-query';

// import { mockClassroomsStats, mockConnectionsStats } from 'src/components/admin/dashboard-statistics/mocks/mocks';
// import { axiosRequest } from 'src/utils/axiosRequest';
// import type { ClassroomsStats, ConnectionsStats } from 'types/statistics.type';

// const isDevelopment = process.env.NODE_ENV === 'development';

// async function getClassroomsStats(): Promise<ClassroomsStats[]> {
// if (isDevelopment) {
// // retourne mocks
// return new Promise((resolve) => {
// setTimeout(() => resolve(mockClassroomsStats), 500);
// });
// }

// return (
// await axiosRequest({
// method: 'GET',
// baseURL: '/api',
// url: '/statistics/classrooms',
// })
// ).data;
// }

// export const useGetClassroomsStats = () => {
// return useQuery(['classrooms-stats'], getClassroomsStats);
// };

// async function getConnectionsStats(): Promise<ConnectionsStats> {
// if (isDevelopment) {
// return new Promise((resolve) => {
// setTimeout(() => resolve(mockConnectionsStats), 500);
// });
// }

// return (
// await axiosRequest({
// method: 'GET',
// baseURL: '/api',
// url: '/statistics/connections',
// })
// ).data;
// }

// export const useGetConnectionsStats = () => {
// return useQuery(['connections-stats'], getConnectionsStats);
// };

import { useQuery } from 'react-query';

import { axiosRequest } from 'src/utils/axiosRequest';
Expand Down
18 changes: 18 additions & 0 deletions src/api/teamComment/teamComment.get.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { useQuery } from 'react-query';

import { axiosRequest } from 'src/utils/axiosRequest';
import type { TeamCommentInterface } from 'types/teamComment.type';

async function getTeamComments(): Promise<TeamCommentInterface> {
return (
await axiosRequest({
method: 'GET',
baseURL: '/api',
url: '/statistics/team-comments',
})
).data;
}

export const useGetSessionsStats = () => {
return useQuery(['team-comments'], () => getTeamComments());
};
2 changes: 1 addition & 1 deletion types/teamComment.type.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export interface TeamCommentInterface {
id: number;
type: number;
type: TeamCommentType;
createDate?: Date | string;
updateDate?: Date | string;
text: string;
Expand Down

0 comments on commit f3f484a

Please sign in to comment.