icssc / peterportal-api-next

API that provides easy access to public data from UC Irvine. Developed for Anteaters, by Anteaters.
https://docs.icssc.club/anteaterapi
MIT License
6 stars 0 forks source link

Cannot return null on non-nullable field #83

Closed MinhxNguyen7 closed 1 year ago

MinhxNguyen7 commented 1 year ago

I think this should work. The structure worked for other queries but not this one, and it's not clear to me why that's the case. Everything works as long as the instructor's name isn't provided, which is what AntAlmanac has been using until now, hence why this was not discovered.

{ 
        aggregateGrades(department: "I&C SCI", courseNumber: "45C", instructor: "SHINDLER, M.") {
            gradeDistribution {
                gradeACount
                gradeBCount
                gradeCCount
                gradeDCount
                gradeFCount
                gradePCount
                gradeNPCount
                averageGPA
            }
        },
    }

I'm marking this as high because it breaks the feature being introduced to Antalmanac (icssc/AntAlmanac#671)

ecxyzzy commented 1 year ago

There's nothing wrong with the structure, the issue is that this query returns an empty set of sections, and we aggregate the data by transforming the raw data. I'm pretty sure this is because I forgot to account for this case, and NaN (result of dividing by the section list length, which might be zero) got coerced to null.

Time to add this case to #81 as a regression test :vulcan_salute:

MinhxNguyen7 commented 1 year ago

How come it returns an empty set? That would imply that Shindler has never taught ICS 45

ecxyzzy commented 1 year ago

That is correct; as of right now, he has never taught ICS 45C. I believe he's scheduled to teach it in the fall, but we won't have the grade distribution info for that until winter.

MinhxNguyen7 commented 1 year ago

Oh yeah I'm being dumb. I was thinking of 46