Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladislav Kanishchev committed Sep 1, 2024
1 parent 351144a commit 92362fc
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 9 deletions.
20 changes: 16 additions & 4 deletions src/apps/shedule/shedule.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,19 @@ export class SheduleService {

async getShedules(query: SheduleGetListDto): Promise<Shedule[]> {
const { grade, groupName, group, startTimeStamp, endTimeStamp, sortByDate, teacher } = query;
const searchQuery: any = { // TODO: remove any
const searchQuery: any = {
// TODO: remove any
date: { $gte: startTimeStamp, $lte: endTimeStamp },
grade,
group,
};

if (grade) {
searchQuery.grade = grade;
}

if (group) {
searchQuery.group = group;
}

if (groupName) {
searchQuery.groupName = groupName;
}
Expand All @@ -46,7 +53,12 @@ export class SheduleService {
try {
await this.sheduleModel
.findOneAndUpdate(
{ groupName: data.groupName, grade: data.grade, group: data.group, date: data.date },
{
groupName: data.groupName,
grade: data.grade,
date: data.date,
teacher: data.teacher,
},
data,
{ upsert: true },
)
Expand Down
15 changes: 12 additions & 3 deletions src/shared/contract/mapper/mstuca-shedule-mapper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class MstucaSheduleMapperService {
fullStat.forEach((sub) => {
const shedule: CreateSheduleDto = {
date: sub.date,
grade: 4,
grade: 0,
group: 1,
discipline: '',
faculty: '',
Expand All @@ -19,16 +19,25 @@ export class MstucaSheduleMapperService {
type: '',
place: '',
teacher: '',
syncedAt: new Date().toISOString(),
};
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;
shedule.grade = sub.stream_facultyoid;
shedule.subgroup = sub.subGroup;

result.push({ ...sub, ...shedule });
if (sub.duration > 2) {
shedule.index = sub.lessonNumberStart;
result.push({ ...shedule });
}

shedule.index = sub.lessonNumberEnd;

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

return result;
Expand Down
4 changes: 4 additions & 0 deletions src/shared/contract/mstuca-api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ export interface MstucaResponse {
lessonNumberStart: number;
stream_facultyoid: number;
stream: string;
subGroup: string | number | null;
subGroupOid: number | null;
subgroup_facultyoid: number | null;
duration: number;
}
5 changes: 4 additions & 1 deletion src/shared/outs/shedule.out.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class SheduleOut {

@IsOptional()
@IsNumber()
declare subgroup?: number;
declare subgroup?: number | string | null;

@IsString()
declare date: string;
Expand All @@ -42,4 +42,7 @@ export class SheduleOut {
@IsOptional()
@IsString()
declare address?: string;

@IsString()
declare syncedAt: string;
}
5 changes: 4 additions & 1 deletion src/shared/schemas/shedule.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class Shedule {
declare group: number;

@Prop()
declare subgroup: number;
declare subgroup: number | string | null;

@Prop({ required: true })
declare date: string;
Expand All @@ -43,6 +43,9 @@ export class Shedule {

@Prop()
declare address: string;

@Prop()
declare syncedAt: string;
}

export const SheduleSchema = SchemaFactory.createForClass(Shedule);

0 comments on commit 92362fc

Please sign in to comment.