Issue:
A course's average data (gpa, enjoyability, etc.) should NOT be fetched on the fly. It needs to be stored within the course model itself, given an instructor and course. We can update these averages on the fly via the following calculation whenever a review is added:
let n = num_of_reviews
let avg = avg_of_some_field
avg += inputted_value / n
avg /= (n + 1)
avg *= n
This will allow us to not have to fetch reviews every time we need to display that data on the department page, course instructor page, or otherwise.
Issue:
A course's average data (gpa, enjoyability, etc.) should NOT be fetched on the fly. It needs to be stored within the course model itself, given an instructor and course. We can update these averages on the fly via the following calculation whenever a review is added:
This will allow us to not have to fetch reviews every time we need to display that data on the department page, course instructor page, or otherwise.