From 67d1525d9806298db6b1e33fa5ed103ada5af127 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Tue, 12 Nov 2019 17:28:33 -0500 Subject: [PATCH] [O] Optimize grading methods by storing them in cookies --- src/components/app/app.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/components/app/app.ts b/src/components/app/app.ts index 2e8d8de..e1b9d32 100644 --- a/src/components/app/app.ts +++ b/src/components/app/app.ts @@ -152,6 +152,12 @@ export default class App extends Vue // Loop through all the courses for (const course of this.filteredCourses) { + // Check if already exist in cookies + if (this.$cookies.isKey('va.grading.' + course.assignmentsId)) + { + course.grading = {method: 'TOTAL_MEAN', weightingMap: {}}; + } + // Request grading scheme for this course App.http.post('/grading', {'assignmentsId': course.assignmentsId}).then(response => { @@ -160,6 +166,13 @@ export default class App extends Vue { // Add it to course course.grading = response.data; + + // If it's total_mean, cache it to cookies + // This is because only percent_type can update over time + if (course.grading.method == 'TOTAL_MEAN') + { + this.$cookies.set('va.grading.' + course.assignmentsId, 'TOTAL_MEAN', '3d'); + } } else throw new Error(response.data); })