New page for all concerts

This commit is contained in:
2024-10-12 19:40:12 +02:00
parent 3204e4a658
commit 60a9cea147
56 changed files with 531 additions and 405 deletions

View File

@@ -1,8 +1,5 @@
import { RatingModel } from "@/data/models/acts/ratingModel"
import { dateToHumanReadableString } from "./dateTimeScripts"
import { ConcertModel } from "@/data/models/acts/concertModel"
import { EventModel } from "@/data/models/acts/eventModel"
import { EventApiModel } from "@/data/models/acts/eventApiModel"
/**
* Calculate a price based on parameters
@@ -18,48 +15,6 @@ export function calcPrice(price: number, quantity: number = 1): number {
}
/**
* 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
}
/**
* Classifies a bunch of ratings to groups from 1 to 5 stars
*
* @param ratings Array of RatingModels
*
* @returns Array of Objects: { value: number[1-5], count: number }
*/
export function calcRatingValues(ratings: Array<RatingModel>) {
let ratingValues = [
{ value: 1, count: 0 },
{ value: 2, count: 0 },
{ value: 3, count: 0 },
{ value: 4, count: 0 },
{ value: 5, count: 0 }
]
for (let rating of ratings) {
ratingValues[rating.rating - 1].count += 1
}
return ratingValues
}
/**
* Create a date range string of all concerts from an Event
*
@@ -104,24 +59,6 @@ export function lowestTicketPrice(concerts: Array<ConcertModel>): string {
priceArray.sort()
try {
return priceArray[0].toFixed(2)
} catch(e) {
return "0"
}
}
export function lowestTicketPriceEvents(events: Array<EventApiModel>) {
const priceArray : Array<number> = []
for (let event of events) {
for (let concert of event.concerts) {
priceArray.push(concert.price)
}
}
priceArray.sort()
try {
return priceArray[0].toFixed(2)
} catch(e) {