Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions public/tutors_list.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
51 changes: 20 additions & 31 deletions src/content/StudentServices/generateTutors.js
Original file line number Diff line number Diff line change
@@ -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();
25 changes: 10 additions & 15 deletions src/pages/StudentServices.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
);
});
}

Expand Down
Loading