[U] Cache numericGrade

This commit is contained in:
Hykilpikonna
2019-12-06 18:07:55 -05:00
parent 7307b179f0
commit 5d2ef0fadf
+5 -10
View File
@@ -193,29 +193,24 @@ export default class Course
}) })
} }
private _cacheNumericGrade: number;
/** /**
* Get numeric grade * Get numeric grade
*/ */
get numericGrade(): number get numericGrade(): number
{ {
// Cached return this.cache.get('NumericGrade', () =>
if (this._cacheNumericGrade == null)
{ {
// Calculate // Calculate
if (this.grading.method == 'PERCENT_TYPE') if (this.grading.method == 'PERCENT_TYPE')
{ {
this._cacheNumericGrade = GPAUtils.getPercentTypeAverage(this, this.assignments); return GPAUtils.getPercentTypeAverage(this, this.assignments);
} }
else if (this.grading.method == 'TOTAL_MEAN') else if (this.grading.method == 'TOTAL_MEAN')
{ {
this._cacheNumericGrade = GPAUtils.getTotalMeanAverage(this.assignments); return GPAUtils.getTotalMeanAverage(this.assignments);
} }
else this._cacheNumericGrade = -1; else return -1;
} })
return this._cacheNumericGrade;
} }
private _cacheAssignmentTypes: AssignmentType[]; private _cacheAssignmentTypes: AssignmentType[];