| | 1 | | using Syki.Back.Features.Student.GetStudentFrequency; |
| | 2 | | using Syki.Back.Features.Student.GetStudentAverageNote; |
| | 3 | |
|
| | 4 | | namespace Syki.Back.Features.Student.GetStudentInsights; |
| | 5 | |
|
| 2 | 6 | | public class GetStudentInsightsService(SykiDbContext ctx, GetStudentFrequencyService frequencyService, GetStudentAverage |
| | 7 | | { |
| | 8 | | public async Task<StudentInsightsOut> Get(Guid userId, Guid courseCurriculumId) |
| | 9 | | { |
| 2 | 10 | | var student = await ctx.Students.FirstAsync(x => x.Id == userId); |
| | 11 | |
|
| 2 | 12 | | var totalDisciplines = await ctx.CourseCurriculumDisciplines.AsNoTracking() |
| 2 | 13 | | .Where(g => g.CourseCurriculumId == courseCurriculumId) |
| 2 | 14 | | .CountAsync(); |
| 2 | 15 | | var finishedDisciplines = await ctx.ClassesStudents |
| 2 | 16 | | .Where(x => x.SykiStudentId == userId && x.StudentDisciplineStatus == StudentDisciplineStatus.Aprovado) |
| 2 | 17 | | .CountAsync(); |
| | 18 | |
|
| 2 | 19 | | var frequency = await frequencyService.Get(userId); |
| | 20 | |
|
| 2 | 21 | | var averageNote = await averageNoteService.Get(userId); |
| | 22 | |
|
| 2 | 23 | | return new() |
| 2 | 24 | | { |
| 2 | 25 | | Status = student.Status, |
| 2 | 26 | | TotalDisciplines = totalDisciplines, |
| 2 | 27 | | FinishedDisciplines = finishedDisciplines, |
| 2 | 28 | | Frequency = frequency.Frequency, |
| 2 | 29 | | Average = averageNote, |
| 2 | 30 | | }; |
| 2 | 31 | | } |
| | 32 | | } |