Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladislav Kanishchev committed Aug 30, 2024
1 parent 3bc8397 commit 351144a
Showing 1 changed file with 21 additions and 27 deletions.
48 changes: 21 additions & 27 deletions src/shared/contract/mapper/mstuca-shedule-mapper.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Injectable } from '@nestjs/common';
import groupBy from 'lodash/groupBy';

import { CreateSheduleDto } from '../../dtos';
import { MstucaResponse } from '../mstuca-api/types';
Expand All @@ -8,33 +7,28 @@ import { MstucaResponse } from '../mstuca-api/types';
export class MstucaSheduleMapperService {
getAllMappedShedule(fullStat: MstucaResponse[]): CreateSheduleDto[] {
const result: CreateSheduleDto[] = [];
fullStat.forEach((sub) => {
const shedule: CreateSheduleDto = {
date: sub.date,
grade: 4,
group: 1,
discipline: '',
faculty: '',
groupName: '',
index: 0,
type: '',
place: '',
teacher: '',
};
shedule.discipline = sub.discipline;
shedule.type = sub.kindOfWork;
shedule.place = sub.auditorium;
shedule.index = sub.lessonNumberStart;
shedule.teacher = sub.lecturer;
shedule.address = sub.building;
shedule.groupName = sub.stream;

const groupedStat = Object.entries(groupBy(fullStat, 'date'));

groupedStat.forEach(([date, item]) => {
item.forEach((sub) => {
const shedule: CreateSheduleDto = {
date,
grade: 4,
group: 1,
discipline: '',
faculty: '',
groupName: '',
index: 0,
type: '',
place: '',
teacher: '',
};
shedule.discipline = sub.discipline;
shedule.type = sub.kindOfWork;
shedule.place = sub.auditorium;
shedule.index = sub.lessonNumberStart;
shedule.teacher = sub.lecturer;
shedule.address = sub.building;
shedule.groupName = sub.stream;

result.push(shedule);
});
result.push({ ...sub, ...shedule });
});

return result;
Expand Down

0 comments on commit 351144a

Please sign in to comment.