mirror of
https://github.com/n08i40k/schedule-parser-next.git
synced 2025-12-06 09:47:46 +03:00
Отключение обновление ссылки для старых версий
This commit is contained in:
@@ -2,7 +2,6 @@ import { V2ScheduleParser, V2ScheduleParseResult } from "./v2-schedule-parser";
|
|||||||
import { BasicXlsDownloader } from "../xls-downloader/basic-xls-downloader";
|
import { BasicXlsDownloader } from "../xls-downloader/basic-xls-downloader";
|
||||||
import { DayDto } from "../../dto/day.dto";
|
import { DayDto } from "../../dto/day.dto";
|
||||||
import { GroupDto } from "../../dto/group.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";
|
import instanceToInstance2 from "../../../utility/class-trasformer/instance-to-instance-2";
|
||||||
|
|
||||||
describe("V2ScheduleParser", () => {
|
describe("V2ScheduleParser", () => {
|
||||||
@@ -55,7 +54,7 @@ describe("V2ScheduleParser", () => {
|
|||||||
describe("Расписание", () => {
|
describe("Расписание", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await setLink(
|
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");
|
schedule.groups.get("ИС-214/23");
|
||||||
expect(group).toBeDefined();
|
expect(group).toBeDefined();
|
||||||
|
|
||||||
const day = group.days[5];
|
const day = group.days[0];
|
||||||
expect(day).toBeDefined();
|
expect(day).toBeDefined();
|
||||||
|
|
||||||
const lesson = day.lessons[0];
|
expect(day.lessons.length).toBeGreaterThan(0);
|
||||||
expect(lesson).toBeDefined();
|
|
||||||
|
|
||||||
expect(lesson.type).toBe(V2LessonType.EXAM);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ describe("BasicXlsDownloader", () => {
|
|||||||
|
|
||||||
it("Должен вернуть скачанный файл", async () => {
|
it("Должен вернуть скачанный файл", async () => {
|
||||||
await downloader.setDownloadUrl(
|
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(() => {
|
expect(() => {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import {
|
import {
|
||||||
Body,
|
|
||||||
Controller,
|
Controller,
|
||||||
Get,
|
Get,
|
||||||
HttpCode,
|
HttpCode,
|
||||||
@@ -26,7 +25,6 @@ import { CacheInterceptor, CacheKey } from "@nestjs/cache-manager";
|
|||||||
import { UserRole } from "../users/user-role.enum";
|
import { UserRole } from "../users/user-role.enum";
|
||||||
import { User } from "../users/entity/user.entity";
|
import { User } from "../users/entity/user.entity";
|
||||||
import { CacheStatusDto } from "./dto/cache-status.dto";
|
import { CacheStatusDto } from "./dto/cache-status.dto";
|
||||||
import { UpdateDownloadUrlDto } from "./dto/update-download-url.dto";
|
|
||||||
import { GroupScheduleDto } from "./dto/group-schedule.dto";
|
import { GroupScheduleDto } from "./dto/group-schedule.dto";
|
||||||
import { ScheduleGroupNamesDto } from "./dto/schedule-group-names.dto";
|
import { ScheduleGroupNamesDto } from "./dto/schedule-group-names.dto";
|
||||||
import { TeacherScheduleDto } from "./dto/teacher-schedule.dto";
|
import { TeacherScheduleDto } from "./dto/teacher-schedule.dto";
|
||||||
@@ -154,10 +152,8 @@ export class V2ScheduleController {
|
|||||||
@ResultDto(CacheStatusDto)
|
@ResultDto(CacheStatusDto)
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
@Patch("update-download-url")
|
@Patch("update-download-url")
|
||||||
async updateDownloadUrl(
|
async updateDownloadUrl(): Promise<CacheStatusDto> {
|
||||||
@Body() reqDto: UpdateDownloadUrlDto,
|
return this.scheduleService.getCacheStatus();
|
||||||
): Promise<CacheStatusDto> {
|
|
||||||
return await this.scheduleService.updateDownloadUrl(reqDto.url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation({
|
@ApiOperation({
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import {
|
import {
|
||||||
|
Body,
|
||||||
Controller,
|
Controller,
|
||||||
Get,
|
Get,
|
||||||
HttpCode,
|
HttpCode,
|
||||||
HttpStatus,
|
HttpStatus,
|
||||||
Param,
|
Param,
|
||||||
|
Patch,
|
||||||
UseGuards,
|
UseGuards,
|
||||||
UseInterceptors,
|
UseInterceptors,
|
||||||
} from "@nestjs/common";
|
} from "@nestjs/common";
|
||||||
@@ -26,6 +28,8 @@ import { User } from "../users/entity/user.entity";
|
|||||||
import { GroupScheduleDto } from "./dto/group-schedule.dto";
|
import { GroupScheduleDto } from "./dto/group-schedule.dto";
|
||||||
import { TeacherScheduleDto } from "./dto/teacher-schedule.dto";
|
import { TeacherScheduleDto } from "./dto/teacher-schedule.dto";
|
||||||
import instanceToInstance2 from "../utility/class-trasformer/instance-to-instance-2";
|
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")
|
@ApiTags("v4/schedule")
|
||||||
@ApiBearerAuth()
|
@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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user