From 71dcf9e8c194f707686d2494231f8485f9bcef3d Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Mon, 27 Apr 2020 17:16:01 -0400 Subject: [PATCH] [O] Make AnalyzedRating a class --- src/logic/course-info.ts | 8 +++++++- src/pages/course-selection/pages/course-detail.vue | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/logic/course-info.ts b/src/logic/course-info.ts index f535ac2..5ad99fd 100644 --- a/src/logic/course-info.ts +++ b/src/logic/course-info.ts @@ -125,9 +125,15 @@ export class CourseInfoRating } } -export interface AnalyzedRating +export class AnalyzedRating { ratingCounts: number[][] ratingSums: number[] totalCount: number + constructor(json: any) + { + this.ratingCounts = json.ratingCounts; + this.ratingSums = json.ratingSums; + this.totalCount = json.totalCount; + } } diff --git a/src/pages/course-selection/pages/course-detail.vue b/src/pages/course-selection/pages/course-detail.vue index 0d05a7b..3ef86bf 100644 --- a/src/pages/course-selection/pages/course-detail.vue +++ b/src/pages/course-selection/pages/course-detail.vue @@ -45,7 +45,7 @@ if (result.success) { // Assign rating - c.rating = result.data as AnalyzedRating; + c.rating = new AnalyzedRating(result.data); } else {