Display all bands grouped by genre, create m:n association between Band and Genre in database
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { RatingModel } from "@/data/models/ratingModel"
|
||||
|
||||
/**
|
||||
* Calculate a price based on parameters
|
||||
*
|
||||
@@ -9,4 +11,21 @@
|
||||
*/
|
||||
export function calcPrice(price: number, discount: number = 0, quantity: number = 1): number {
|
||||
return Math.round(quantity * price * ((100 - discount) / 100) * 100) / 100
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the average of an Array of ratings
|
||||
*
|
||||
* @param ratings Array of ratings
|
||||
*
|
||||
* @returns Average rating as number
|
||||
*/
|
||||
export function calcRating(ratings: Array<RatingModel>) {
|
||||
let sum = 0
|
||||
|
||||
for (let rating of ratings) {
|
||||
sum += rating.rating
|
||||
}
|
||||
|
||||
return sum / ratings.length
|
||||
}
|
||||
Reference in New Issue
Block a user