Отключение обновление ссылки для старых версий

This commit is contained in:
2024-12-13 06:03:11 +04:00
parent c79052c8d4
commit e9e10ad17e
4 changed files with 29 additions and 14 deletions

View File

@@ -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);
});
});
});

View File

@@ -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(() => {

View File

@@ -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<CacheStatusDto> {
return await this.scheduleService.updateDownloadUrl(reqDto.url);
async updateDownloadUrl(): Promise<CacheStatusDto> {
return this.scheduleService.getCacheStatus();
}
@ApiOperation({

View File

@@ -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<CacheStatusDto> {
return await this.scheduleService.updateDownloadUrl(reqDto.url);
}
}