-
Notifications
You must be signed in to change notification settings - Fork 2
Setting up helper functions for flowchart ai #370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,47 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const TERM_MAP = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "-1": "Skip", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1: "Fall", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2: "Winter", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3: "Spring", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5: "Fall", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6: "Winter", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7: "Spring", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9: "Fall", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10: "Winter", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11: "Spring", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13: "Fall", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14: "Winter", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15: "Spring", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17: "Fall", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18: "Winter", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19: "Spring", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21: "Fall", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22: "Winter", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23: "Spring", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25: "Fall", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26: "Winter", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27: "Spring", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29: "Fall", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30: "Winter", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31: "Spring", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+28
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const TERM_MAP = { | |
| "-1": "Skip", | |
| 1: "Fall", | |
| 2: "Winter", | |
| 3: "Spring", | |
| 5: "Fall", | |
| 6: "Winter", | |
| 7: "Spring", | |
| 9: "Fall", | |
| 10: "Winter", | |
| 11: "Spring", | |
| 13: "Fall", | |
| 14: "Winter", | |
| 15: "Spring", | |
| 17: "Fall", | |
| 18: "Winter", | |
| 19: "Spring", | |
| 21: "Fall", | |
| 22: "Winter", | |
| 23: "Spring", | |
| 25: "Fall", | |
| 26: "Winter", | |
| 27: "Spring", | |
| 29: "Fall", | |
| 30: "Winter", | |
| 31: "Spring", | |
| }; | |
| export const getTermName = (tIndex: number): string => { | |
| if (tIndex === -1) return "Skip"; | |
| const terms = ["Fall", "Winter", "Spring"]; | |
| const adjustedIndex = (tIndex - 1) % 3; // Adjust to 0-based index for modulo | |
| return terms[adjustedIndex]; | |
| }; | |
| export const TERM_MAP = new Proxy({}, { | |
| get: (_, prop: string) => { | |
| const tIndex = parseInt(prop, 10); | |
| if (isNaN(tIndex)) { | |
| throw new Error(`Invalid term index: ${prop}`); | |
| } | |
| return getTermName(tIndex); | |
| } | |
| }); |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,8 +12,12 @@ import { | |||||||||||||||||||||||||||||||
| SelectedSection, | ||||||||||||||||||||||||||||||||
| ProfessorRatingDocument, | ||||||||||||||||||||||||||||||||
| SectionAddedOrRemoved, | ||||||||||||||||||||||||||||||||
| AcademicPlan, | ||||||||||||||||||||||||||||||||
| } from "@polylink/shared/types"; | ||||||||||||||||||||||||||||||||
| import { fetchPrimaryFlowchart } from "../../../db/models/flowchart/flowchartServices"; | ||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||
| fetchPrimaryFlowchart, | ||||||||||||||||||||||||||||||||
| fetchPrimaryFlowchartDoc, | ||||||||||||||||||||||||||||||||
| } from "../../../db/models/flowchart/flowchartServices"; | ||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||
| getSectionsByCourseIds, | ||||||||||||||||||||||||||||||||
| getSectionsByIds, | ||||||||||||||||||||||||||||||||
|
|
@@ -30,6 +34,18 @@ import { | |||||||||||||||||||||||||||||||
| SUGGESTED_SECTIONS_PER_COURSE, | ||||||||||||||||||||||||||||||||
| POTENTIAL_SECTIONS_PER_COURSE, | ||||||||||||||||||||||||||||||||
| } from "./const"; | ||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||
| getCatalogYear, | ||||||||||||||||||||||||||||||||
| TERM_MAP, | ||||||||||||||||||||||||||||||||
| } from "../../../db/models/flowchart/flowchartHelpers"; | ||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||
| getGeCourses, | ||||||||||||||||||||||||||||||||
| getGeSubjects, | ||||||||||||||||||||||||||||||||
| } from "../../../db/models/courses/courseServices"; | ||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||
| getGeAreas, | ||||||||||||||||||||||||||||||||
| getTechElectivesCourses, | ||||||||||||||||||||||||||||||||
| } from "../../../db/models/courses/courseServices"; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| export const getAlternateSections = async ({ | ||||||||||||||||||||||||||||||||
| userId, | ||||||||||||||||||||||||||||||||
|
|
@@ -88,7 +104,12 @@ export const getUserNextEligibleSections = async ({ | |||||||||||||||||||||||||||||||
| potentialSectionsClassNums: number[]; | ||||||||||||||||||||||||||||||||
| }> => { | ||||||||||||||||||||||||||||||||
| const flowchart = await fetchPrimaryFlowchart(userId); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if (!flowchart) { | ||||||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||||||
| suggestedSections: [], | ||||||||||||||||||||||||||||||||
| potentialSectionsClassNums: [], | ||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| // Sort terms by tIndex | ||||||||||||||||||||||||||||||||
| const terms = (flowchart.termData || []).sort( | ||||||||||||||||||||||||||||||||
| (a: Term, b: Term) => a.tIndex - b.tIndex | ||||||||||||||||||||||||||||||||
|
|
@@ -596,3 +617,142 @@ export async function buildSectionSummaries( | |||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||
| return summaries; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
| /** | |
| * Retrieves a summary of the academic plan (flowchart) for a given user. | |
| * | |
| * @param {string} userId - The unique identifier of the user whose flowchart is being retrieved. | |
| * @returns {Promise<AcademicPlan | null>} A promise that resolves to the academic plan summary | |
| * or null if no flowchart is found for the user. | |
| * | |
| * @remarks | |
| * This function fetches the primary flowchart document for the user and processes its data | |
| * to generate a textual summary of the academic plan. It includes details such as the major, | |
| * concentration, and term-specific information. If the user does not have a flowchart, the | |
| * function returns null. | |
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the unused imports
TechElectiveDocumentandTechElectivefrom this file to reduce clutter and avoid unnecessary module dependencies.