feat: add absence notification and analytics features
- Implemented AbsenceNotifyView for notifying absence with session details. - Created AnalyticsView for displaying group analytics and managing students at risk. - Added ClassAttendanceView for marking attendance in classes. - Defined new schemas for analytics and attendance in shared package.
This commit is contained in:
67
packages/shared/src/schemas/analytics.ts
Normal file
67
packages/shared/src/schemas/analytics.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
import { z } from 'zod';
|
||||
import { attendanceStatusSchema } from './attendance.js';
|
||||
|
||||
const isoDateTimeSchema = z.string().datetime();
|
||||
|
||||
export const attendeeStatusSchema = z.enum(['ACTIVE', 'PAUSED', 'DROPPED']);
|
||||
export type AttendeeStatus = z.output<typeof attendeeStatusSchema>;
|
||||
|
||||
export const riskLevelSchema = z.enum(['HIGH', 'MEDIUM']);
|
||||
export type RiskLevel = z.output<typeof riskLevelSchema>;
|
||||
|
||||
export const GroupAnalyticsSchema = z.object({
|
||||
attendanceRate: z.number().min(0).max(100),
|
||||
totalPresent: z.number().int().min(0),
|
||||
totalClasses: z.number().int().min(0),
|
||||
recoveredSlots: z.number().int().min(0),
|
||||
});
|
||||
export type GroupAnalytics = z.output<typeof GroupAnalyticsSchema>;
|
||||
export type GroupAnalyticsDto = GroupAnalytics;
|
||||
|
||||
export const StudentAtRiskSchema = z.object({
|
||||
attendeeId: z.string(),
|
||||
fullName: z.string(),
|
||||
phone: z.string().nullable(),
|
||||
riskLevel: riskLevelSchema,
|
||||
consecutiveAbsences: z.number().int().min(0),
|
||||
lastAttendedAt: isoDateTimeSchema.nullable(),
|
||||
monthlyAttendanceRate: z.number().min(0).max(100),
|
||||
});
|
||||
export type StudentAtRisk = z.output<typeof StudentAtRiskSchema>;
|
||||
export type StudentAtRiskDto = StudentAtRisk;
|
||||
|
||||
export const StudentsAtRiskSchema = z.object({
|
||||
groupName: z.string(),
|
||||
data: z.array(StudentAtRiskSchema),
|
||||
});
|
||||
export type StudentsAtRisk = z.output<typeof StudentsAtRiskSchema>;
|
||||
export type StudentsAtRiskDto = StudentsAtRisk;
|
||||
|
||||
export const AttendanceHistoryItemSchema = z.object({
|
||||
classSessionId: z.string(),
|
||||
startsAt: isoDateTimeSchema,
|
||||
status: attendanceStatusSchema.nullable(),
|
||||
});
|
||||
export type AttendanceHistoryItem = z.output<typeof AttendanceHistoryItemSchema>;
|
||||
|
||||
export const AttendeeHistorySchema = z.object({
|
||||
attendeeId: z.string(),
|
||||
fullName: z.string(),
|
||||
groupId: z.string(),
|
||||
groupName: z.string(),
|
||||
attendanceRate: z.number().min(0).max(100),
|
||||
sessions: z.array(AttendanceHistoryItemSchema),
|
||||
});
|
||||
export type AttendeeHistory = z.output<typeof AttendeeHistorySchema>;
|
||||
export type AttendeeHistoryDto = AttendeeHistory;
|
||||
|
||||
export const UpdateStudentStatusSchema = z.object({
|
||||
status: attendeeStatusSchema,
|
||||
});
|
||||
export type UpdateStudentStatus = z.output<typeof UpdateStudentStatusSchema>;
|
||||
|
||||
export const UpdateStudentStatusResultSchema = z.object({
|
||||
attendeeId: z.string(),
|
||||
status: attendeeStatusSchema,
|
||||
});
|
||||
export type UpdateStudentStatusResult = z.output<typeof UpdateStudentStatusResultSchema>;
|
||||
Reference in New Issue
Block a user