Remove EventModel in frontend

This commit is contained in:
2024-10-12 21:00:42 +02:00
parent 6c33de3d87
commit c8d87f6643
33 changed files with 313 additions and 377 deletions

View File

@@ -13,6 +13,9 @@ export const band = Router()
// Get all bands
band.get("/", (req: Request, res: Response) => {
let sort = req.query.sort
let count = req.query.count
Band.findAll({
include: [
{
@@ -35,13 +38,28 @@ band.get("/", (req: Request, res: Response) => {
// Delete unnecessary Arrays
delete band.dataValues.ratings
delete band.dataValues.concerts
for (let genre of band.dataValues.genres) {
delete genre.dataValues.BandGenre
}
}
// Sort ascending/descending by number of concerts
if (sort != undefined) {
bands.sort((band1, band2) => {
if (sort == "desc") {
return band2.dataValues.concerts.length - band1.dataValues.concerts.length
} else if (sort == "asc") {
return band1.dataValues.concerts.length - band2.dataValues.concerts.length
}
})
}
// Limit number of items
if (count != undefined) {
bands.splice(Number(count))
}
res.status(200).json(bands)
})
})