Skip to content

Commit

Permalink
Debug roadmap
Browse files Browse the repository at this point in the history
  • Loading branch information
erica-dong committed Jan 14, 2024
1 parent cc23498 commit 4fbcb47
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
11 changes: 6 additions & 5 deletions src/components/Dashboard/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { auth, logout } from "../../Firebase.js";
import RequestUtils from "../../Utils/RequestUtils.js";
import { useAuthState } from "react-firebase-hooks/auth";

const data = require('./courses.json');
const data = require('./Courses.json');
const { Option } = Select;
const { Header, Sider, Content } = Layout;

Expand Down Expand Up @@ -92,12 +92,13 @@ function Dashboard() {
let y = 0;

function setCourses() {
console.log(data);
console.log(department);
tempCourses = [];
tempEdges = [];
courseTracking = [];
let encounteredCodes = new Set();

for (var i = 0; i < data.Report_Entry.length; i++) {
for (let i = 0; i < data.Report_Entry.length; i++) {
if (
data.Report_Entry[i]["Course_Section_Owner"] == department &&
!courseTracking.includes(data.Report_Entry[i]["Course_Title"])
Expand Down Expand Up @@ -141,7 +142,7 @@ function Dashboard() {
})
// // Print the extracted course codes

for (var j = 0; j < tempCourses.length; j++) {
for (let j = 0; j < tempCourses.length; j++) {
if (courseCodes.length > 0) {
for (var k = 0; k < courseCodes.length; k++) {
if (
Expand Down Expand Up @@ -177,7 +178,7 @@ function Dashboard() {
tempCourses.push({
id: i - 1 + data.Report_Entry.length,
data: { label: (i == 7 ? 'Grad' : i + '000') + 'Courses' },
style: { display: "none" },
// style: { },
type: 'group',
courseType: i,
courseCode: "",
Expand Down
19 changes: 12 additions & 7 deletions src/components/Dashboard/Flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ import ReactFlow, {
import 'reactflow/dist/style.css';
import DataParse from '../DataParse/DataParse';

import profRatings from '../DataParse/ProfessorRating.json';
import classRatings from '../DataParse/CourseRatings.json';
import data from "../DataParse/prod-data.json"
import profRatingsJSON from '../DataParse/ProfessorRating.json';
import classRatingsJSON from '../DataParse/CourseRatings.json';

const elk = new ELK();
const elkOptions = {
Expand All @@ -34,7 +33,7 @@ const lerpColor = (h1, h2, progress) => {
return `hsl(${h1 + Math.round((h2-h1) * progress)}, 100%, 80%)`
}

const getLayoutedElements = (nodes, edges, colorSchema, coursesTaken, options = {}) => {
const getLayoutedElements = (nodes, edges, colorSchema, coursesTaken, profRatings, classRatings, options = {}) => {
const easyColor = 125;
const hardColor = -50;
const codesLeft = new Set();
Expand All @@ -46,8 +45,8 @@ const getLayoutedElements = (nodes, edges, colorSchema, coursesTaken, options =
const courseRating = classRatings[node.courseCode] ? classRatings[node.courseCode] : Math.round(Math.random() * 100);
const profRating = profRatings[node.professor] ? profRatings[node.professor] : Math.round(Math.random() * 100);
// shouldn't be nan so often
if(profRatings[node.professor] == NaN) console.log(node.professor);
const projRating = 0.6 * profRating + 0.4 * courseRating;
// console.log(profRatings[node.professor] + " " + node.professor)

let gradRe = new RegExp("[A-Z]{2,3} [5-9][0-9]*")
let style = {};
Expand All @@ -71,6 +70,9 @@ const getLayoutedElements = (nodes, edges, colorSchema, coursesTaken, options =
style.backgroundColor = "rgb(138, 138, 138)";
style.color = "rgb(225, 225, 225)";
}
if (node.type === "group") {
style.display = "none";
}

return {
...node,
Expand Down Expand Up @@ -110,6 +112,9 @@ function FlowWithoutProvider({initialNodes, initialEdges, colorSchema, coursesTa
const [edges, setEdges, onEdgesChange] = useEdgesState([]);
const { fitView } = useReactFlow();

const [profRatings, setProfRatings] = useState(profRatingsJSON);
const [classRatings, setClassRatings] = useState(classRatingsJSON);

let [courseCode, setCourseCode] = useState("");

const onConnect = useCallback((params) => setEdges((eds) => addEdge(params, eds)), []);
Expand All @@ -119,14 +124,14 @@ function FlowWithoutProvider({initialNodes, initialEdges, colorSchema, coursesTa
const ns = useInitialNodes ? initialNodes : nodes;
const es = useInitialNodes ? initialEdges : edges;

getLayoutedElements(ns, es, colorSchema, coursesTaken, opts).then(({ nodes: layoutedNodes, edges: layoutedEdges }) => {
getLayoutedElements(ns, es, colorSchema, coursesTaken, profRatings, classRatings, opts).then(({ nodes: layoutedNodes, edges: layoutedEdges }) => {
setNodes(layoutedNodes);
setEdges(layoutedEdges);

window.requestAnimationFrame(() => fitView());
});
},
[nodes, edges, initialNodes, initialEdges, colorSchema, coursesTaken]
[nodes, edges, initialNodes, initialEdges, colorSchema, coursesTaken, profRatings, classRatings]
);

useLayoutEffect(() => {
Expand Down

0 comments on commit 4fbcb47

Please sign in to comment.