[U] Cache numericGrade
This commit is contained in:
+5
-10
@@ -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[];
|
||||||
|
|||||||
Reference in New Issue
Block a user