From c390a9d53eced6e8c4bd0102b940c23ca8c4fea3 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Sat, 23 Mar 2024 17:56:55 -0700 Subject: [PATCH] Lint fixes --- package.json | 3 ++- prisma/seed.ts | 1 + src/buildings/buildings.controller.ts | 4 +++- src/cache/cache.module.ts | 2 +- src/courses/courses.controller.ts | 6 +++-- src/courses/types.ts | 4 +++- src/instructors/instructors.controller.ts | 6 +++-- src/interceptors/no-cache-updated-since.ts | 6 ++--- src/lib/convert-semester-type.ts | 13 +++++++---- src/lib/db-utils.ts | 12 +++++----- src/lib/parse-location.ts | 11 ++++----- src/main.ts | 10 ++++---- src/passfaildrop/passfaildrop.controller.ts | 17 +++++++------- src/pool/pool.module.ts | 9 ++++---- src/sections/sections.controller.ts | 4 +++- src/sections/types.ts | 4 +++- src/semesters/semesters.controller.ts | 4 +++- src/tasks/scrape-ratemyprofessors.ts | 2 +- src/tasks/scrape-section-details.ts | 6 ++--- src/tasks/scrape-sections.ts | 23 +++++++++---------- src/tasks/scrape-transfer-courses.ts | 20 ++++++++-------- src/tests/fixtures/fetcher-fake.ts | 7 +++--- src/tests/fixtures/get-test-service.ts | 3 +-- src/tests/lib/parse-location.test.ts | 3 +-- .../tasks/scrape-section-details.test.ts | 14 +++++------ .../tasks/scrape-sections/sections.test.ts | 4 ++-- .../tasks/scrape-transfer-courses.test.ts | 20 ++++++++-------- .../transfer-courses.controller.ts | 4 +++- 28 files changed, 120 insertions(+), 102 deletions(-) diff --git a/package.json b/package.json index a10a1ee..0663357 100644 --- a/package.json +++ b/package.json @@ -148,7 +148,8 @@ "@typescript-eslint/comma-dangle": "off", "@typescript-eslint/naming-convention": "off", "n/prefer-global/process": "off", - "unicorn/no-await-expression-member": "off" + "unicorn/no-await-expression-member": "off", + "@typescript-eslint/no-unsafe-argument": "off" } }, "prisma": { diff --git a/prisma/seed.ts b/prisma/seed.ts index d1be284..31d281d 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -19,6 +19,7 @@ seed() // eslint-disable-next-line unicorn/no-process-exit process.exit(1); }) + // eslint-disable-next-line unicorn/prefer-top-level-await .finally(async () => { await prisma.$disconnect(); }); diff --git a/src/buildings/buildings.controller.ts b/src/buildings/buildings.controller.ts index 7cd9416..3bb9b70 100644 --- a/src/buildings/buildings.controller.ts +++ b/src/buildings/buildings.controller.ts @@ -1,4 +1,6 @@ -import {Controller, Get, Header, Injectable} from '@nestjs/common'; +import { + Controller, Get, Header, Injectable +} from '@nestjs/common'; import * as db from 'zapatos/db'; import {PoolService} from '~/pool/pool.service'; diff --git a/src/cache/cache.module.ts b/src/cache/cache.module.ts index b4236e0..7a00cbf 100644 --- a/src/cache/cache.module.ts +++ b/src/cache/cache.module.ts @@ -1,5 +1,5 @@ import {Module} from '@nestjs/common'; -import {CacheModule as Cache} from "@nestjs/cache-manager" +import {CacheModule as Cache} from '@nestjs/cache-manager'; @Module({ imports: [ diff --git a/src/courses/courses.controller.ts b/src/courses/courses.controller.ts index 92f595a..9ca9cdf 100644 --- a/src/courses/courses.controller.ts +++ b/src/courses/courses.controller.ts @@ -1,11 +1,13 @@ -import {Controller, Get, Injectable, Query, Res, UseInterceptors} from '@nestjs/common'; +import { + Controller, Get, Injectable, Query, Res, UseInterceptors +} from '@nestjs/common'; import {FastifyReply} from 'fastify'; import {NoCacheUpdatedSinceInterceptor} from 'src/interceptors/no-cache-updated-since'; +import {CacheKey} from '@nestjs/cache-manager'; import {CoursesService} from './courses.service'; import {GetCoursesParameters, GetUniqueCoursesParameters, FindFirstCourseParameters} from './types'; import {streamSqlQuery} from '~/lib/stream-sql-query'; import {PoolService} from '~/pool/pool.service'; -import { CacheKey } from '@nestjs/cache-manager'; @Controller('courses') @UseInterceptors(NoCacheUpdatedSinceInterceptor) diff --git a/src/courses/types.ts b/src/courses/types.ts index 84368a0..08d2fd0 100644 --- a/src/courses/types.ts +++ b/src/courses/types.ts @@ -1,4 +1,6 @@ -import {IsDate, IsIn, IsNumber, IsOptional} from 'class-validator'; +import { + IsDate, IsIn, IsNumber, IsOptional +} from 'class-validator'; import {Type} from 'class-transformer'; import {ApiProperty} from '@nestjs/swagger'; import {Semester} from '@prisma/client'; diff --git a/src/instructors/instructors.controller.ts b/src/instructors/instructors.controller.ts index ef49ac7..6a09499 100644 --- a/src/instructors/instructors.controller.ts +++ b/src/instructors/instructors.controller.ts @@ -1,10 +1,12 @@ -import {Controller, Get, Header, Injectable, Query, UseInterceptors} from '@nestjs/common'; +import { + Controller, Get, Header, Injectable, Query, UseInterceptors +} from '@nestjs/common'; import {Thumbor} from '@mtucourses/thumbor'; import {NoCacheUpdatedSinceInterceptor} from 'src/interceptors/no-cache-updated-since'; import * as db from 'zapatos/db'; +import {CacheInterceptor} from '@nestjs/cache-manager'; import {GetInstructorsParameters} from './types'; import {PoolService} from '~/pool/pool.service'; -import { CacheInterceptor } from '@nestjs/cache-manager'; @Controller('instructors') @UseInterceptors(CacheInterceptor, NoCacheUpdatedSinceInterceptor) diff --git a/src/interceptors/no-cache-updated-since.ts b/src/interceptors/no-cache-updated-since.ts index d6a9577..68c5079 100644 --- a/src/interceptors/no-cache-updated-since.ts +++ b/src/interceptors/no-cache-updated-since.ts @@ -1,7 +1,7 @@ -import type {CallHandler, ExecutionContext, NestInterceptor} from '@nestjs/common'; -import {Injectable} from '@nestjs/common'; +import { + Injectable, type CallHandler, type ExecutionContext, type NestInterceptor +} from '@nestjs/common'; // NestJS bug: https://stackoverflow.com/a/63984129/12638523 - import type {FastifyReply} from 'fastify'; @Injectable() diff --git a/src/lib/convert-semester-type.ts b/src/lib/convert-semester-type.ts index d153c9d..29fa223 100644 --- a/src/lib/convert-semester-type.ts +++ b/src/lib/convert-semester-type.ts @@ -3,13 +3,16 @@ import type {Semester} from 'zapatos/schema'; export const fetcherSemesterToDatabaseSemester = (semester: ESemester): Semester => { switch (semester) { - case ESemester.fall: + case ESemester.fall: { return 'FALL'; - case ESemester.spring: + } + + case ESemester.spring: { return 'SPRING'; - case ESemester.summer: + } + + case ESemester.summer: { return 'SUMMER'; - default: - throw new Error('Invalid semester'); + } } }; diff --git a/src/lib/db-utils.ts b/src/lib/db-utils.ts index f5ac1e6..f051f2b 100644 --- a/src/lib/db-utils.ts +++ b/src/lib/db-utils.ts @@ -1,18 +1,18 @@ import type * as schema from 'zapatos/schema'; import * as db from 'zapatos/db'; -export const mapWithSeparator = ( +export const mapWithSeparator = ( array: TIn[], - separator: TSep, - cb: (x: TIn, i: number, a: TIn[]) => TOut -): Array => { - const result: Array = []; + separator: TSeparator, + callback: (x: TIn, i: number, a: TIn[]) => TOut +): Array => { + const result: Array = []; for (let i = 0, length = array.length; i < length; i++) { if (i > 0) { result.push(separator); } - result.push(cb(array[i], i, array)); + result.push(callback(array[i], i, array)); } return result; diff --git a/src/lib/parse-location.ts b/src/lib/parse-location.ts index 6be7f01..58c69e7 100644 --- a/src/lib/parse-location.ts +++ b/src/lib/parse-location.ts @@ -1,7 +1,6 @@ -import type {Building, Section} from '@prisma/client'; -import {LocationType} from '@prisma/client'; +import {LocationType, type Building, type Section} from '@prisma/client'; -const numbersRegex = new RegExp(/(\d)\w+/); +const numbersRegex = /(\d)\w+/; const getMappedBuildingName = (buildingName: string, buildings: Building[]) => { const building = buildings.find(b => b.name === buildingName); @@ -49,13 +48,13 @@ const parseLocation = (from: string, buildings: Building[]): Pick>((acc, row) => { + return result.reduce>((accumulator, row) => { const key = `${row.courseSubject}${row.courseCrse}`; - acc[key] = [ - ...(acc[key] ?? []), + accumulator[key] = [ + ...(accumulator[key] ?? []), { semester: row.semester, year: row.year, @@ -52,7 +53,7 @@ export class PassFailDropController { } ]; - return acc; + return accumulator; }, {}); } diff --git a/src/pool/pool.module.ts b/src/pool/pool.module.ts index 64ad85f..4a5920b 100644 --- a/src/pool/pool.module.ts +++ b/src/pool/pool.module.ts @@ -1,5 +1,4 @@ -import type {OnApplicationShutdown} from '@nestjs/common'; -import {Module} from '@nestjs/common'; +import {Module, type OnApplicationShutdown} from '@nestjs/common'; import {ModuleRef} from '@nestjs/core'; import {PoolService} from './pool.service'; @@ -10,15 +9,15 @@ import {PoolService} from './pool.service'; exports: [PoolService] }) export class PoolModule implements OnApplicationShutdown { - constructor(private readonly moduleRef: ModuleRef) { - moduleRef.get(PoolService).on('error', error => { + constructor(private readonly moduleReference: ModuleRef) { + moduleReference.get(PoolService).on('error', error => { // eslint-disable-next-line unicorn/no-process-exit process.exit(1); }); } async onApplicationShutdown() { - const pool = this.moduleRef.get(PoolService); + const pool = this.moduleReference.get(PoolService); await pool.end(); } } diff --git a/src/sections/sections.controller.ts b/src/sections/sections.controller.ts index 25b5bbf..528f143 100644 --- a/src/sections/sections.controller.ts +++ b/src/sections/sections.controller.ts @@ -1,4 +1,6 @@ -import {Controller, Get, Injectable, Query, UseInterceptors, Res} from '@nestjs/common'; +import { + Controller, Get, Injectable, Query, UseInterceptors, Res +} from '@nestjs/common'; import {FastifyReply} from 'fastify'; import {NoCacheUpdatedSinceInterceptor} from 'src/interceptors/no-cache-updated-since'; import {GetSectionsParameters, FindFirstSectionParamters} from './types'; diff --git a/src/sections/types.ts b/src/sections/types.ts index f9d29ae..9617482 100644 --- a/src/sections/types.ts +++ b/src/sections/types.ts @@ -1,4 +1,6 @@ -import {IsDate, IsIn, IsNumber, IsOptional} from 'class-validator'; +import { + IsDate, IsIn, IsNumber, IsOptional +} from 'class-validator'; import {Type} from 'class-transformer'; import {ApiProperty} from '@nestjs/swagger'; import {Semester} from '@prisma/client'; diff --git a/src/semesters/semesters.controller.ts b/src/semesters/semesters.controller.ts index 2b63c1c..b4b2feb 100644 --- a/src/semesters/semesters.controller.ts +++ b/src/semesters/semesters.controller.ts @@ -1,4 +1,6 @@ -import {Controller, Get, Header, Injectable} from '@nestjs/common'; +import { + Controller, Get, Header, Injectable +} from '@nestjs/common'; import * as db from 'zapatos/db'; import {PoolService} from '~/pool/pool.service'; diff --git a/src/tasks/scrape-ratemyprofessors.ts b/src/tasks/scrape-ratemyprofessors.ts index cecb996..4eb42b1 100644 --- a/src/tasks/scrape-ratemyprofessors.ts +++ b/src/tasks/scrape-ratemyprofessors.ts @@ -37,7 +37,7 @@ export class ScrapeRateMyProfessorsTask { })(async (instructor: schema.JSONSelectableForTable<'Instructor'>) => { const nameFragments = instructor.fullName.split(' '); const firstName = nameFragments[0]; - const lastName = nameFragments[nameFragments.length - 1]; + const lastName = nameFragments.at(-1); const results = await this.fetcher.rateMyProfessors.searchTeacher(`${firstName} ${lastName}`, schools[0].id); diff --git a/src/tasks/scrape-section-details.ts b/src/tasks/scrape-section-details.ts index 314414c..3632625 100644 --- a/src/tasks/scrape-section-details.ts +++ b/src/tasks/scrape-section-details.ts @@ -93,7 +93,7 @@ export class ScrapeSectionDetailsTask { const scrapedSectionDetailsWithNulls = await Promise.all(sections.map(async section => { try { - const extScrapedDetails = await this.throttledGetSectionDetails({ + const extensionScrapedDetails = await this.throttledGetSectionDetails({ subject: section.course.subject, crse: section.course.crse, crn: section.crn, @@ -101,7 +101,7 @@ export class ScrapeSectionDetailsTask { }); return { - extScrapedDetails, + extScrapedDetails: extensionScrapedDetails, section }; } catch (error: unknown) { @@ -222,7 +222,7 @@ export class ScrapeSectionDetailsTask { const fragments = name.split(' '); return { firstName: fragments[0], - lastName: fragments[fragments.length - 1], + lastName: fragments.at(-1), fullName: name }; }); diff --git a/src/tasks/scrape-sections.ts b/src/tasks/scrape-sections.ts index 1d5c4fc..bd0a48b 100644 --- a/src/tasks/scrape-sections.ts +++ b/src/tasks/scrape-sections.ts @@ -1,8 +1,7 @@ import {Injectable, Logger} from '@nestjs/common'; import pThrottle from 'p-throttle'; import type {ICourseOverview, ISection} from '@mtucourses/scraper'; -import type {IRuleOptions} from 'src/lib/rschedule'; -import {Schedule} from 'src/lib/rschedule'; +import {Schedule, type IRuleOptions} from 'src/lib/rschedule'; import {calculateDiffInTime, dateToTerm, mapDayCharToRRScheduleString} from 'src/lib/dates'; import getTermsToProcess from 'src/lib/get-terms-to-process'; import {Task, TaskHandler} from 'nestjs-graphile-worker'; @@ -30,9 +29,9 @@ export class ScrapeSectionsTask { private async processTerm(term: Date) { const {semester, year} = dateToTerm(term); - let extCourses: ICourseOverview[] = []; + let extensionCourses: ICourseOverview[] = []; try { - extCourses = await this.fetcher.getAllSections(term); + extensionCourses = await this.fetcher.getAllSections(term); } catch (error: unknown) { if (error instanceof Error && error.message === 'Banner services are currently down.') { this.logger.warn('Banner services are currently down. Skipping scraping instructors.'); @@ -56,15 +55,15 @@ export class ScrapeSectionsTask { }).run(trx); // Upsert courses - await db.upsert('Course', extCourses.map(extCourse => { - const [minCredits, maxCredits] = this.getCreditsRangeFromCourse(extCourse); + await db.upsert('Course', extensionCourses.map(extensionCourse => { + const [minCredits, maxCredits] = this.getCreditsRangeFromCourse(extensionCourse); return { year, semester, - subject: extCourse.subject, - crse: extCourse.crse, - title: extCourse.title, + subject: extensionCourse.subject, + crse: extensionCourse.crse, + title: extensionCourse.title, minCredits, maxCredits, }; @@ -77,12 +76,12 @@ export class ScrapeSectionsTask { }).run(trx); // Upsert sections - const sectionsUpsertInput: Array> = extCourses.flatMap(extCourse => extCourse.sections.map(extSection => { - const section = this.reshapeSectionFromScraperToDatabase(extSection, year); + const sectionsUpsertInput: Array> = extensionCourses.flatMap(extensionCourse => extensionCourse.sections.map(extensionSection => { + const section = this.reshapeSectionFromScraperToDatabase(extensionSection, year); return { ...section, - courseId: db.sql`(SELECT ${'id'} FROM ${'Course'} WHERE ${'year'} = ${db.param(year)} AND ${'semester'} = ${db.param(semester)} AND ${'subject'} = ${db.param(extCourse.subject)} AND ${'crse'} = ${db.param(extCourse.crse)})` + courseId: db.sql`(SELECT ${'id'} FROM ${'Course'} WHERE ${'year'} = ${db.param(year)} AND ${'semester'} = ${db.param(semester)} AND ${'subject'} = ${db.param(extensionCourse.subject)} AND ${'crse'} = ${db.param(extensionCourse.crse)})` }; })); diff --git a/src/tasks/scrape-transfer-courses.ts b/src/tasks/scrape-transfer-courses.ts index 60b1084..fe82500 100644 --- a/src/tasks/scrape-transfer-courses.ts +++ b/src/tasks/scrape-transfer-courses.ts @@ -15,9 +15,9 @@ export class ScrapeTransferCoursesTask { @TaskHandler() async handler() { - let extTransferCourses: ITransferCourse[] = []; + let extensionTransferCourses: ITransferCourse[] = []; try { - extTransferCourses = await this.fetcher.getAllTransferCourses(); + extensionTransferCourses = await this.fetcher.getAllTransferCourses(); } catch (error: unknown) { if (error instanceof Error && error.message === 'Banner services are currently down.') { this.logger.warn('Banner services are currently down. Skipping scraping instructors.'); @@ -27,28 +27,28 @@ export class ScrapeTransferCoursesTask { // Filter out duplicates // todo: this should be handled by the scraper - const extUniqueTransferCoursesMap = new Map(); + const extensionUniqueTransferCoursesMap = new Map(); - for (const course of extTransferCourses) { + for (const course of extensionTransferCourses) { const key = `${course.from.college}-${course.from.crse}-${course.from.subject}-${course.to.crse}-${course.to.subject}-${course.to.credits}`; - if (!extUniqueTransferCoursesMap.has(key)) { - extUniqueTransferCoursesMap.set(key, course); + if (!extensionUniqueTransferCoursesMap.has(key)) { + extensionUniqueTransferCoursesMap.set(key, course); } } - const extUniqueTransferCourses = Array.from(extUniqueTransferCoursesMap.values()); + const extensionUniqueTransferCourses = Array.from(extensionUniqueTransferCoursesMap.values()); - this.logger.log(`Scraped ${extTransferCourses.length} transfer courses (${extUniqueTransferCourses.length} unique ones)...`); + this.logger.log(`Scraped ${extensionTransferCourses.length} transfer courses (${extensionUniqueTransferCourses.length} unique ones)...`); const startedUpdatingAt = new Date(); await db.serializable(this.pool, async trx => { // Batch updates - for (let i = 0; i <= extUniqueTransferCourses.length; i += 100) { + for (let i = 0; i <= extensionUniqueTransferCourses.length; i += 100) { // eslint-disable-next-line no-await-in-loop await db.upsert( 'TransferCourse', - extUniqueTransferCourses.slice(i, i + 100).map(course => ({ + extensionUniqueTransferCourses.slice(i, i + 100).map(course => ({ fromCollege: course.from.college, fromCollegeState: course.from.state, fromCRSE: course.from.crse, diff --git a/src/tests/fixtures/fetcher-fake.ts b/src/tests/fixtures/fetcher-fake.ts index 869c757..ebe8d15 100644 --- a/src/tests/fixtures/fetcher-fake.ts +++ b/src/tests/fixtures/fetcher-fake.ts @@ -1,7 +1,8 @@ import type {ISchoolFromSearch, ITeacherPage} from '@mtucourses/rate-my-professors'; -import type {ICourseOverview, IFaculty, ISection, ISectionDetails, ITransferCourse} from '@mtucourses/scraper'; -import {ESemester} from '@mtucourses/scraper'; -import type scraper from '@mtucourses/scraper'; +// eslint-disable-next-line @typescript-eslint/consistent-type-imports +import scraper, { + ESemester, ICourseOverview, IFaculty, ISection, ISectionDetails, ITransferCourse +} from '@mtucourses/scraper'; import {Semester} from '@prisma/client'; import type {Except} from 'type-fest'; import type {AbstractFetcherService, RateMyProfessorsFetcher} from '~/fetcher/fetcher.service'; diff --git a/src/tests/fixtures/get-test-service.ts b/src/tests/fixtures/get-test-service.ts index 3716287..dd80196 100644 --- a/src/tests/fixtures/get-test-service.ts +++ b/src/tests/fixtures/get-test-service.ts @@ -1,8 +1,7 @@ import {Test} from '@nestjs/testing'; import type {Type} from '@nestjs/common'; import {PrismaClient} from '@prisma/client'; -import type {GetTestDatabaseOptions} from './get-test-database'; -import {getTestDatabase} from './get-test-database'; +import {getTestDatabase, type GetTestDatabaseOptions} from './get-test-database'; import {FakeFetcherService} from './fetcher-fake'; import {FetcherModule} from '~/fetcher/fetcher.module'; import {FetcherService} from '~/fetcher/fetcher.service'; diff --git a/src/tests/lib/parse-location.test.ts b/src/tests/lib/parse-location.test.ts index 25d932b..ed120b9 100644 --- a/src/tests/lib/parse-location.test.ts +++ b/src/tests/lib/parse-location.test.ts @@ -1,5 +1,4 @@ -import type {Building} from '@prisma/client'; -import {LocationType} from '@prisma/client'; +import {LocationType, type Building} from '@prisma/client'; import test from 'ava'; import parseLocation from '~/lib/parse-location'; diff --git a/src/tests/tasks/scrape-section-details.test.ts b/src/tests/tasks/scrape-section-details.test.ts index 2732f33..0f0ec18 100644 --- a/src/tests/tasks/scrape-section-details.test.ts +++ b/src/tests/tasks/scrape-section-details.test.ts @@ -215,14 +215,14 @@ test.serial('updates course description', async t => { seedSections: true, }); - const [extCourse] = fetcherFake.courses; + const [extensionCourse] = fetcherFake.courses; await service.handler({ terms: [getFirstTermFromFake()], }); const course = await prisma.course.findFirstOrThrow(); - t.is(course.description, extCourse.sectionDetails[0].extSectionDetails.description); + t.is(course.description, extensionCourse.sectionDetails[0].extSectionDetails.description); // Update description fetcherFake.putFirstSectionDetails({ @@ -324,14 +324,14 @@ test.serial('works with multiple sections taught by the same instructor', async seedSections: true, }); - const [firstExtCourse] = fetcherFake.courses; + const [firstExtensionCourse] = fetcherFake.courses; const createdCourse = await prisma.course.create({ data: { subject: 'MA', crse: '1101', - year: firstExtCourse.year, - semester: firstExtCourse.semester, + year: firstExtensionCourse.year, + semester: firstExtensionCourse.semester, title: 'Calculus I', } }); @@ -372,10 +372,10 @@ test.serial('works with multiple sections taught by the same instructor', async fee: createdSection.fee, schedules: [], instructors: [ - firstExtCourse.extSections[0].instructors[0], + firstExtensionCourse.extSections[0].instructors[0], ] }], - sectionDetails: firstExtCourse.sectionDetails, + sectionDetails: firstExtensionCourse.sectionDetails, year: createdCourse.year, semester: createdCourse.semester, } diff --git a/src/tests/tasks/scrape-sections/sections.test.ts b/src/tests/tasks/scrape-sections/sections.test.ts index 76ebb06..d0b83b4 100644 --- a/src/tests/tasks/scrape-sections/sections.test.ts +++ b/src/tests/tasks/scrape-sections/sections.test.ts @@ -76,7 +76,7 @@ test.serial('adds back a section that was deleted', async t => { seedSections: true, }); - const [extSection] = fetcherFake.courses[0].extSections; + const [extensionSection] = fetcherFake.courses[0].extSections; fetcherFake.courses[0].extSections = []; @@ -88,7 +88,7 @@ test.serial('adds back a section that was deleted', async t => { // Add section back fetcherFake.courses[0].extSections = [ - extSection + extensionSection ]; await service.handler({ diff --git a/src/tests/tasks/scrape-transfer-courses.test.ts b/src/tests/tasks/scrape-transfer-courses.test.ts index ba81d0f..64e2f03 100644 --- a/src/tests/tasks/scrape-transfer-courses.test.ts +++ b/src/tests/tasks/scrape-transfer-courses.test.ts @@ -7,20 +7,20 @@ test.serial('scrapes successfully', async t => { await service.handler(); - const [extTransferCourse] = fetcherFake.transferCourses; + const [extensionTransferCourse] = fetcherFake.transferCourses; const transferCourse = await prisma.transferCourse.findFirstOrThrow(); t.like(transferCourse, { - fromCollege: extTransferCourse.from.college, - fromCollegeState: extTransferCourse.from.state, - fromCRSE: extTransferCourse.from.crse, - fromSubject: extTransferCourse.from.subject, - fromCredits: extTransferCourse.from.credits, - toCRSE: extTransferCourse.to.crse, - toSubject: extTransferCourse.to.subject, - toCredits: extTransferCourse.to.credits, - title: extTransferCourse.to.title, + fromCollege: extensionTransferCourse.from.college, + fromCollegeState: extensionTransferCourse.from.state, + fromCRSE: extensionTransferCourse.from.crse, + fromSubject: extensionTransferCourse.from.subject, + fromCredits: extensionTransferCourse.from.credits, + toCRSE: extensionTransferCourse.to.crse, + toSubject: extensionTransferCourse.to.subject, + toCredits: extensionTransferCourse.to.credits, + title: extensionTransferCourse.to.title, }); }); diff --git a/src/transfer-courses/transfer-courses.controller.ts b/src/transfer-courses/transfer-courses.controller.ts index b29847b..0dbef55 100644 --- a/src/transfer-courses/transfer-courses.controller.ts +++ b/src/transfer-courses/transfer-courses.controller.ts @@ -1,4 +1,6 @@ -import {Controller, Get, Header, Injectable, Query, UseInterceptors} from '@nestjs/common'; +import { + Controller, Get, Header, Injectable, Query, UseInterceptors +} from '@nestjs/common'; import {NoCacheUpdatedSinceInterceptor} from 'src/interceptors/no-cache-updated-since'; import * as db from 'zapatos/db'; import type {WhereableForTable} from 'zapatos/schema';