CSS-CaveHill-Campus / advising-matrix

https://advising-matrix.netlify.app
0 stars 1 forks source link

Degree majors on feat/majors #17

Closed aquonbovell closed 3 months ago

aquonbovell commented 3 months ago

Can you check the getCourses function, it is working for those majors that have electives @ level 1. But fails for those non elective ones (Biochemistry).

Here is the error:

error: syntax error at or near ")"
    at C:\Users\aquon\Code\advising-matrix\node_modules\pg\lib\client.js:526:17
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async PostgresConnection.executeQuery (file:///C:/Users/aquon/Code/advising-matrix/node_modules/kysely/dist/esm/dialect/postgres/postgres-driver.js:69:28)
    at async file:///C:/Users/aquon/Code/advising-matrix/node_modules/kysely/dist/esm/query-executor/query-executor-base.js:35:28
    at async DefaultConnectionProvider.provideConnection (file:///C:/Users/aquon/Code/advising-matrix/node_modules/kysely/dist/esm/driver/default-connection-provider.js:10:20)
    at async DefaultQueryExecutor.executeQuery (file:///C:/Users/aquon/Code/advising-matrix/node_modules/kysely/dist/esm/query-executor/query-executor-base.js:34:16)
    at async SelectQueryBuilderImpl.execute (file:///C:/Users/aquon/Code/advising-matrix/node_modules/kysely/dist/esm/query-builder/select-query-builder.js:309:24)
    at async Promise.all (index 0)
    at async getCourses (C:\Users\aquon\Code\advising-matrix\src\routes\(protected)\student\degree-tracker\+page.server.ts:65:35)
    at async Promise.all (index 1)
    at PostgresConnection.executeQuery (file:///C:/Users/aquon/Code/advising-matrix/node_modules/kysely/dist/esm/dialect/postgres/postgres-driver.js:89:41)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async file:///C:/Users/aquon/Code/advising-matrix/node_modules/kysely/dist/esm/query-executor/query-executor-base.js:35:28
    at async DefaultConnectionProvider.provideConnection (file:///C:/Users/aquon/Code/advising-matrix/node_modules/kysely/dist/esm/driver/default-connection-provider.js:10:20)
    at async DefaultQueryExecutor.executeQuery (file:///C:/Users/aquon/Code/advising-matrix/node_modules/kysely/dist/esm/query-executor/query-executor-base.js:34:16)
    at async SelectQueryBuilderImpl.execute (file:///C:/Users/aquon/Code/advising-matrix/node_modules/kysely/dist/esm/query-builder/select-query-builder.js:309:24)
    at async Promise.all (index 0)
    at async getCourses (C:\Users\aquon\Code\advising-matrix\src\routes\(protected)\student\degree-tracker\+page.server.ts:65:35)
    at async Promise.all (index 1)
    at async load (C:\Users\aquon\Code\advising-matrix\src\routes\(protected)\student\degree-tracker\+page.server.ts:168:60) {
  length: 90,
  severity: 'ERROR',
  code: '42601',
  detail: undefined,
  hint: undefined,
  position: '39',
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'scan.l',
  line: '1188',
  routine: 'scanner_yyerror'
}
phrogwrld commented 3 months ago

the only thing i am thinking is that the array is coming back empty. The problem is either here:

        getCourses(
            program.requirements.flatMap((req) =>
                req.type === 'CREDITS' && 'courses' in req.details ? req.details.courses : []
            )
        ),

or

async function getCourses(courseIds: string[]): Promise<CourseWithPrerequisites[]> {
    const [courses, prerequisites] = await Promise.all([
        db.selectFrom('Course').where('id', 'in', courseIds).selectAll().execute(),
        db
            .selectFrom('CoursePrerequisite as CP')
            .innerJoin('Course as C', 'CP.prerequisiteId', 'C.id')
            .where('CP.courseId', 'in', courseIds)
//...

but from me looking at what was saved, it looks correct

  {
    "id": "7ad333a2-e383-453c-b0e0-6d5b7debc303",
    "programId": "2d334c72-bf96-413a-a73a-d40bcb14068d",
    "type": "CREDITS",
    "credits": 24,
    "details": {
      "courses": [
        "9290",
        "7719",
        "12966",
        "7720",
        "12994",
        "378",
        "12993",
        "12992"
      ]
    }
  },
aquonbovell commented 3 months ago

The error was thrown in the get courses function. So maybe it's there.

I'll take a slower look later