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

add Api call, clean statistics api call, change type type in teamComm… #986

Merged
merged 2 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 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
Loading