diff --git a/public/tutors_list.json b/public/tutors_list.json new file mode 100644 index 0000000..b40d4c0 --- /dev/null +++ b/public/tutors_list.json @@ -0,0 +1,77 @@ +[ + { + "email": "xkhan2@illinois.edu", + "name": "Xainab Khan", + "courses": "ECE 110, ECE 120, PHYS 211, PHYS 212, MATH 221, MATH 231, MATH 241, MATH 257, MATH 285, CS 173" + }, + { + "email": "da24@illinois.edu", + "name": "Dominic Andrejek", + "courses": "ECE 110, ECE 210, PHYS 213, MATH 221, MATH 231, MATH 241, MATH 285" + }, + { + "email": "ayushtm2@illinois.edu", + "name": "Ayush Mehendale", + "courses": "ECE 110, ECE 120, ECE 210, ECE 220, PHYS 211, PHYS 212, PHYS 213, PHYS 214, MATH 221, MATH 231, MATH 241, MATH 257, MATH 285, CS 173" + }, + { + "email": "msorial2@illinois.edu", + "name": "Mark Sorial", + "courses": "ECE 110, ECE 120, ECE 220, MATH 221, MATH 231, CS 173, CS 225" + }, + { + "email": "rbahary2@illinois.edu", + "name": "Ryan Bahary", + "courses": "CS 225" + }, + { + "email": "pjz3@illinois.edu", + "name": "Patrick", + "courses": "ECE 110, ECE 120, ECE 220" + }, + { + "email": "jqunell2@illinois.edu", + "name": "Jonathan Qunell", + "courses": "ECE 110, ECE 120, ECE 210, ECE 220, PHYS 211, PHYS 212, PHYS 213, PHYS 214, MATH 257, MATH 285" + }, + { + "email": "lau29@illinois.edu", + "name": "Sarah Lau", + "courses": "ECE 110, ECE 210, PHYS 211, PHYS 213, PHYS 214, MATH 257, MATH 285" + }, + { + "email": "wsturn2@illinois.edu", + "name": "Wyatt Sturn", + "courses": "ECE 110, ECE 120, ECE 210, PHYS 211, PHYS 212, PHYS 213, PHYS 214, MATH 221, MATH 231, MATH 241, MATH 257, MATH 285" + }, + { + "email": "pola3@illinois.edu", + "name": "Aditya Pola", + "courses": "ECE 110, ECE 120, ECE 220, PHYS 212, CS 173" + }, + { + "email": "qixuan3@illinois.edu", + "name": "Keeron Huang", + "courses": "ECE 110, ECE 120, ECE 210, ECE 220, ECE 330, CS 225" + }, + { + "email": "mtrigo2@illinois.edu", + "name": "Mateus", + "courses": "ECE 110, ECE 120, ECE 220, ECE 310, ECE 313, PHYS 211, PHYS 212, MATH 221, MATH 231, MATH 241, MATH 257, CS 225" + }, + { + "email": "muqixu2@illinois.edu", + "name": "Barry Xu", + "courses": "ECE 110, ECE 120, ECE 210, ECE 220, ECE 310, PHYS 211, PHYS 212, PHYS 213, PHYS 214, CS 173" + }, + { + "email": "ns58@illinois.edu", + "name": "Nick Schroeder", + "courses": "ECE 110, ECE 120, ECE 210, PHYS 211, PHYS 212, PHYS 214, MATH 285" + }, + { + "email": "lau29@illinois.edu", + "name": "Sarah Lau", + "courses": "ECE 110, ECE 210, PHYS 211, PHYS 213, PHYS 214, MATH 257, MATH 285" + } +] \ No newline at end of file diff --git a/src/content/StudentServices/generateTutors.js b/src/content/StudentServices/generateTutors.js index 2e1f966..f09a101 100644 --- a/src/content/StudentServices/generateTutors.js +++ b/src/content/StudentServices/generateTutors.js @@ -1,40 +1,29 @@ import fs from "fs"; -import { google } from "googleapis"; +import fetch from "node-fetch"; -const credentials = JSON.parse(process.env.SHEETS_API_KEY); +const SHEET_ID = "1QKaLo1SVdvRPeqQNGBiCWWA70IFAbrZEl2YvLN9470s"; +const url = `https://docs.google.com/spreadsheets/d/${SHEET_ID}/gviz/tq?tqx=out:json`; -const auth = new google.auth.GoogleAuth({ - credentials, - scopes: ["https://www.googleapis.com/auth/spreadsheets.readonly"], -}); +async function generate() { + const res = await fetch(url); + const text = await res.text(); -const sheets = google.sheets({ version: "v4", auth }); + const json = JSON.parse(text.substring(47).slice(0, -2)); -const SHEET_ID = "1WnuVYrK_CKNv2iooqLCqYOpvyX8U401lMseo0DQ-Kd8"; -const RANGE = "Form Responses 1!A:E"; + const rows = json.table.rows; -async function generate() { - try { const response = await sheets.spreadsheets.values.get({ - spreadsheetId: SHEET_ID, - range: RANGE, - }); - - const rows = response.data.values; - - const tutors = rows.slice(1).map(row => ({ - email: row[1] || "", - name: row[2] || "", - courses: row[4] || "", - })); - - fs.writeFileSync( - "./public/tutors_list.json", - JSON.stringify(tutors, null, 2) - ); - console.log("tutors_list.json generated!"); - } catch (error) { - console.error("Error:", error) - } + const tutors = rows.map(row => ({ + email: row.c[0]?.v || "", + name: row.c[1]?.v || "", + courses: row.c[4]?.v || "" + })); + + fs.writeFileSync( + "./public/tutors_list.json", + JSON.stringify(tutors, null, 2) + ); + + console.log("tutors_list.json generated!"); } generate(); \ No newline at end of file diff --git a/src/pages/StudentServices.svelte b/src/pages/StudentServices.svelte index 03b4f0f..5a4927d 100644 --- a/src/pages/StudentServices.svelte +++ b/src/pages/StudentServices.svelte @@ -26,21 +26,16 @@ const standardizedTutorCourses = tutor.courses .split(",") .map(standardizeClassName); - let found = false; - requestedCourses.forEach((c) => { - found = - found || - standardizedTutorCourses.includes(c) || - standardizedTutorCourses.reduce( - (v, x) => - v || - (c.length >= 3 && - c[0].toLowerCase() == c[0].toUpperCase() && - x.includes(c)), - false - ); - }); - return found; + + return requestedCourses.some((c) => + standardizedTutorCourses.includes(c) || + standardizedTutorCourses.some( + (x) => + c.length >= 3 && + /^\d/.test(c) && + x.includes(c) + ) + ); }); }