From e9e10ad17e23a756981cfda0091b1edeb466f5cb Mon Sep 17 00:00:00 2001 From: N08I40K Date: Fri, 13 Dec 2024 06:03:11 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=82=D0=BA=D0=BB=D1=8E=D1=87=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D1=81=D1=81=D1=8B=D0=BB=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D1=81=D1=82=D0=B0=D1=80=D1=8B=D1=85=20?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v2-schedule-parser.spec.ts | 10 +++----- .../basic-xls-downloader.spec.ts | 2 +- src/schedule/v2-schedule.controller.ts | 8 ++----- src/schedule/v4-schedule.controller.ts | 23 +++++++++++++++++++ 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/schedule/internal/schedule-parser/v2-schedule-parser.spec.ts b/src/schedule/internal/schedule-parser/v2-schedule-parser.spec.ts index 9f73986..c8813ca 100644 --- a/src/schedule/internal/schedule-parser/v2-schedule-parser.spec.ts +++ b/src/schedule/internal/schedule-parser/v2-schedule-parser.spec.ts @@ -2,7 +2,6 @@ import { V2ScheduleParser, V2ScheduleParseResult } from "./v2-schedule-parser"; import { BasicXlsDownloader } from "../xls-downloader/basic-xls-downloader"; import { DayDto } from "../../dto/day.dto"; import { GroupDto } from "../../dto/group.dto"; -import { V2LessonType } from "../../enum/v2-lesson-type.enum"; import instanceToInstance2 from "../../../utility/class-trasformer/instance-to-instance-2"; describe("V2ScheduleParser", () => { @@ -55,7 +54,7 @@ describe("V2ScheduleParser", () => { describe("Расписание", () => { beforeEach(async () => { await setLink( - "https://politehnikum-eng.ru/2024/poltavskaja_14_s_2_po_8_12.xls", + "https://politehnikum-eng.ru/2024/poltavskaja_15_s_9_po_13.12-1-.xls", ); }); @@ -74,13 +73,10 @@ describe("V2ScheduleParser", () => { schedule.groups.get("ИС-214/23"); expect(group).toBeDefined(); - const day = group.days[5]; + const day = group.days[0]; expect(day).toBeDefined(); - const lesson = day.lessons[0]; - expect(lesson).toBeDefined(); - - expect(lesson.type).toBe(V2LessonType.EXAM); + expect(day.lessons.length).toBeGreaterThan(0); }); }); }); diff --git a/src/schedule/internal/xls-downloader/basic-xls-downloader.spec.ts b/src/schedule/internal/xls-downloader/basic-xls-downloader.spec.ts index 5016017..933319c 100644 --- a/src/schedule/internal/xls-downloader/basic-xls-downloader.spec.ts +++ b/src/schedule/internal/xls-downloader/basic-xls-downloader.spec.ts @@ -23,7 +23,7 @@ describe("BasicXlsDownloader", () => { it("Должен вернуть скачанный файл", async () => { await downloader.setDownloadUrl( - "https://politehnikum-eng.ru/2024/poltavskaja_07_s_14_po_20_10-5-.xls", + "https://politehnikum-eng.ru/2024/poltavskaja_15_s_9_po_13.12-1-.xls", ); expect(() => { diff --git a/src/schedule/v2-schedule.controller.ts b/src/schedule/v2-schedule.controller.ts index 7b9bd73..0409269 100644 --- a/src/schedule/v2-schedule.controller.ts +++ b/src/schedule/v2-schedule.controller.ts @@ -1,5 +1,4 @@ import { - Body, Controller, Get, HttpCode, @@ -26,7 +25,6 @@ import { CacheInterceptor, CacheKey } from "@nestjs/cache-manager"; import { UserRole } from "../users/user-role.enum"; import { User } from "../users/entity/user.entity"; import { CacheStatusDto } from "./dto/cache-status.dto"; -import { UpdateDownloadUrlDto } from "./dto/update-download-url.dto"; import { GroupScheduleDto } from "./dto/group-schedule.dto"; import { ScheduleGroupNamesDto } from "./dto/schedule-group-names.dto"; import { TeacherScheduleDto } from "./dto/teacher-schedule.dto"; @@ -154,10 +152,8 @@ export class V2ScheduleController { @ResultDto(CacheStatusDto) @HttpCode(HttpStatus.OK) @Patch("update-download-url") - async updateDownloadUrl( - @Body() reqDto: UpdateDownloadUrlDto, - ): Promise { - return await this.scheduleService.updateDownloadUrl(reqDto.url); + async updateDownloadUrl(): Promise { + return this.scheduleService.getCacheStatus(); } @ApiOperation({ diff --git a/src/schedule/v4-schedule.controller.ts b/src/schedule/v4-schedule.controller.ts index 0ecf002..7e773c2 100644 --- a/src/schedule/v4-schedule.controller.ts +++ b/src/schedule/v4-schedule.controller.ts @@ -1,9 +1,11 @@ import { + Body, Controller, Get, HttpCode, HttpStatus, Param, + Patch, UseGuards, UseInterceptors, } from "@nestjs/common"; @@ -26,6 +28,8 @@ import { User } from "../users/entity/user.entity"; import { GroupScheduleDto } from "./dto/group-schedule.dto"; import { TeacherScheduleDto } from "./dto/teacher-schedule.dto"; import instanceToInstance2 from "../utility/class-trasformer/instance-to-instance-2"; +import { CacheStatusDto } from "./dto/cache-status.dto"; +import { UpdateDownloadUrlDto } from "./dto/update-download-url.dto"; @ApiTags("v4/schedule") @ApiBearerAuth() @@ -102,4 +106,23 @@ export class V4ScheduleController { }), ); } + + @ApiOperation({ summary: "Обновление основной страницы политехникума" }) + @ApiResponse({ + status: HttpStatus.OK, + description: "Данные обновлены успешно", + type: CacheStatusDto, + }) + @ApiResponse({ + status: HttpStatus.NOT_ACCEPTABLE, + description: "Передан некорректный код страницы", + }) + @ResultDto(CacheStatusDto) + @HttpCode(HttpStatus.OK) + @Patch("update-download-url") + async updateDownloadUrl( + @Body() reqDto: UpdateDownloadUrlDto, + ): Promise { + return await this.scheduleService.updateDownloadUrl(reqDto.url); + } }