From e6f1b5f08b550bf56751706308fd520398189f35 Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Wed, 15 May 2024 16:40:10 -0700 Subject: [PATCH] =?UTF-8?q?style:=20=F0=9F=8E=A8=20variable=20naming?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/departments-terms-scraper/src/index.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/services/departments-terms-scraper/src/index.ts b/services/departments-terms-scraper/src/index.ts index 90071a02..90d30bca 100644 --- a/services/departments-terms-scraper/src/index.ts +++ b/services/departments-terms-scraper/src/index.ts @@ -7,7 +7,9 @@ async function fetchWebSoc() { return load(body); } -async function getDepartments($: CheerioAPI): Promise { +async function getDepartments(webSocContent: CheerioAPI): Promise { + const $ = webSocContent; + const departments: string[] = []; $('select[name="Dept"] option').each((_index, element) => { const deptText = $(element).text().trim(); @@ -20,7 +22,9 @@ async function getDepartments($: CheerioAPI): Promise { return departments; } -async function getTerms($: CheerioAPI): Promise { +async function getTerms(webSocContent: CheerioAPI): Promise { + const $ = webSocContent; + const terms: string[] = []; $('select[name="YearTerm"] option').each((_index, element) => { const termText = $(element).text().trim(); @@ -31,12 +35,14 @@ async function getTerms($: CheerioAPI): Promise { } async function getDepartmentsTerms() { - const $ = await fetchWebSoc(); + const webSocContent = await fetchWebSoc(); - const terms = await getTerms($); - const departments = await getDepartments($); + const terms = await getTerms(webSocContent); + const departments = await getDepartments(webSocContent); return { departments, terms }; } +getDepartmentsTerms().then(console.log); + export default getDepartmentsTerms;