diff --git a/software/backend/routes/band.routes.ts b/software/backend/routes/band.routes.ts index f6aeafa..bc4a9f5 100644 --- a/software/backend/routes/band.routes.ts +++ b/software/backend/routes/band.routes.ts @@ -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) }) }) diff --git a/software/backend/routes/concert.routes.ts b/software/backend/routes/concert.routes.ts index 38ee75c..fe83466 100644 --- a/software/backend/routes/concert.routes.ts +++ b/software/backend/routes/concert.routes.ts @@ -12,6 +12,8 @@ export const concert = Router() concert.get("/", (req: Request, res: Response) => { + let count = req.query.count + Concert.findAll({ include: [ Band, Location ], order: [ @@ -19,6 +21,11 @@ concert.get("/", (req: Request, res: Response) => { ] }) .then(concerts => { + // Limit number of items + if (count != undefined) { + concerts.splice(Number(count)) + } + res.status(200).json(concerts) }) }) diff --git a/software/backend/routes/location.routes.ts b/software/backend/routes/location.routes.ts index e77b5fd..b8e19d1 100644 --- a/software/backend/routes/location.routes.ts +++ b/software/backend/routes/location.routes.ts @@ -27,6 +27,7 @@ location.get("/", (req: Request, res: Response) => { } }) .then(async locations => { + // Sort ascending/descending by number of concerts if (sort != undefined) { locations.sort((location1, location2) => { if (sort == "desc") { diff --git a/software/backend/scripts/databaseHelper.ts b/software/backend/scripts/databaseHelper.ts index 0650dea..b53c135 100644 --- a/software/backend/scripts/databaseHelper.ts +++ b/software/backend/scripts/databaseHelper.ts @@ -226,7 +226,7 @@ export async function prepopulateDatabase() { date: concert.date, name: concertGroup.name, price: concert.price, - image: concertGroup.name, + image: concertGroup.image, inStock: concert.inStock, offered: true, bandId: dataset.dataValues.id, diff --git a/software/src/components/navigation/navigationAppendItems.vue b/software/src/components/navigation/navigationAppendItems.vue index 025090a..47ffd03 100644 --- a/software/src/components/navigation/navigationAppendItems.vue +++ b/software/src/components/navigation/navigationAppendItems.vue @@ -1,7 +1,6 @@ \ No newline at end of file diff --git a/software/src/pages/bands/bandDetailPage/gallerySection.vue b/software/src/pages/bands/bandDetailPage/gallerySection.vue index 913517d..ff420ea 100644 --- a/software/src/pages/bands/bandDetailPage/gallerySection.vue +++ b/software/src/pages/bands/bandDetailPage/gallerySection.vue @@ -1,8 +1,8 @@