zaimimr / Snittet

Snitt kalkulator for NTNU studenter
https://snitt.zaim.no
4 stars 1 forks source link

Problems when adding certain courses #2

Open Molnes opened 9 months ago

Molnes commented 9 months ago

If adding a course like IDATA1001 it adds it, but if you try adding IFYA1001 it does nothing. Seems to be an unhandled 404 response. image

Error: Uncaught (in promise) Error: Request failed with status code 404 exports createError.js:16 exports settle.js:17 y xhr.js:54 exports xhr.js:60 exports xhr.js:13 exports dispatchRequest.js:53 request Axios.js:108 e Axios.js:129 exports bind.js:9 k service.ts:47 k Searchbar.tsx:38 onChange Searchbar.tsx:77 et useAutocomplete.js:542 nt useAutocomplete.js:582 ft useAutocomplete.js:888 React 11 unstable_runWithPriority scheduler.production.min.js:18 React 14 unstable_runWithPriority scheduler.production.min.js:18 React 10 unstable_runWithPriority scheduler.production.min.js:18 React 3 createError.js:16:14

callumgran commented 9 months ago

It seems that there are multiple subjects that are searchable, but don't exists as object.\ When looking through the API, I found that most of the newer courses for the Computer Science Bachelor's Degree Programme don't exists, but their older counterparts do. Maybe it is possible to get a new dump of data from fsweb?

Example:\ image

{
    "database": "projects/snittet-49dac/databases/(default)",
    "addTarget": {
        "query": {
            "structuredQuery": {
                "from": [
                    {
                        "collectionId": "Subjects"
                    }
                ],
                "where": {
                    "compositeFilter": {
                        "op": "AND",
                        "filters": [
                            {
                                "fieldFilter": {
                                    "field": {
                                        "fieldPath": "code"
                                    },
                                    "op": "GREATER_THAN_OR_EQUAL",
                                    "value": {
                                        "stringValue": "IDATT2101"
                                    }
                                }
                            },
                            {
                                "fieldFilter": {
                                    "field": {
                                        "fieldPath": "code"
                                    },
                                    "op": "LESS_THAN",
                                    "value": {
                                        "stringValue": "IDATT2101z"
                                    }
                                }
                            }
                        ]
                    }
                },
                "orderBy": [
                    {
                        "field": {
                            "fieldPath": "code"
                        },
                        "direction": "ASCENDING"
                    },
                    {
                        "field": {
                            "fieldPath": "__name__"
                        },
                        "direction": "ASCENDING"
                    }
                ],
                "limit": 5
            },
            "parent": "projects/snittet-49dac/databases/(default)/documents"
        },
        "targetId": 152
    }
}

As you can see it can be searched, but when requested, the following is responded.

Request:

GET /api/v2/courses/idatt2101/ HTTP/2
Host: grades.no
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/118.0
Accept: application/json, text/plain, */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Origin: https://snitt.zaim.no
Connection: keep-alive
Referer: https://snitt.zaim.no/
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: cross-site

Response:

HTTP/2 404 
date: Sun, 03 Dec 2023 15:29:15 GMT
content-type: application/json
content-length: 23
allow: GET, PUT, PATCH, DELETE, HEAD, OPTIONS
x-frame-options: DENY
vary: Cookie, Origin
access-control-allow-origin: *
X-Firefox-Spdy: h2