Remove EventTable in database, redesign frontend URL paths
This commit is contained in:
@@ -3,7 +3,6 @@ import { Band } from "../models/acts/band.model";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { Rating } from "../models/acts/rating.model";
|
||||
import { Genre } from "../models/acts/genre.model";
|
||||
import { Event } from "../models/acts/event.model";
|
||||
import { Concert } from "../models/acts/concert.model";
|
||||
import { Location } from "../models/locations/location.model";
|
||||
import { City } from "../models/locations/city.model";
|
||||
@@ -28,26 +27,18 @@ band.get("/", (req: Request, res: Response) => {
|
||||
}
|
||||
},
|
||||
{
|
||||
model: Event,
|
||||
model: Concert,
|
||||
include: [
|
||||
{
|
||||
model: Concert,
|
||||
include: [
|
||||
{
|
||||
model: Location,
|
||||
include: [ City ],
|
||||
attributes: {
|
||||
exclude: [ "id" ]
|
||||
}
|
||||
}
|
||||
],
|
||||
model: Location,
|
||||
include: [ City ],
|
||||
attributes: {
|
||||
exclude: [ "id", "tourId", "locationId" ]
|
||||
exclude: [ "id" ]
|
||||
}
|
||||
}
|
||||
],
|
||||
attributes: {
|
||||
exclude: [ "id", "bandId" ]
|
||||
exclude: [ "id", "tourId", "locationId" ]
|
||||
}
|
||||
},
|
||||
Genre
|
||||
@@ -78,26 +69,18 @@ band.get("/band/:name", (req: Request, res: Response) => {
|
||||
}
|
||||
},
|
||||
{
|
||||
model: Event,
|
||||
model: Concert,
|
||||
include: [
|
||||
{
|
||||
model: Concert,
|
||||
include: [
|
||||
{
|
||||
model: Location,
|
||||
include: [ City ],
|
||||
attributes: {
|
||||
exclude: [ "id" ]
|
||||
}
|
||||
}
|
||||
],
|
||||
model: Location,
|
||||
include: [ City ],
|
||||
attributes: {
|
||||
exclude: [ "tourId", "locationId" ]
|
||||
exclude: [ "id" ]
|
||||
}
|
||||
}
|
||||
],
|
||||
attributes: {
|
||||
exclude: [ "bandId" ]
|
||||
exclude: [ "tourId", "locationId" ]
|
||||
}
|
||||
},
|
||||
Genre
|
||||
@@ -120,17 +103,7 @@ band.get("/search", (req: Request, res: Response) => {
|
||||
[Op.substring]: req.query.value
|
||||
},
|
||||
},
|
||||
include: [
|
||||
{
|
||||
model: Event,
|
||||
include: [
|
||||
Concert
|
||||
]
|
||||
},
|
||||
{
|
||||
model: Genre
|
||||
}
|
||||
]
|
||||
include: [ Concert, Genre ]
|
||||
})
|
||||
.then(bands => {
|
||||
res.status(200).json(bands)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Location } from "../models/locations/location.model";
|
||||
import { Concert } from "../models/acts/concert.model";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { Event } from "../models/acts/event.model";
|
||||
import { City } from "../models/locations/city.model";
|
||||
import { SeatGroup } from "../models/locations/seatGroup.model";
|
||||
import { SeatRow } from "../models/locations/seatRow.model";
|
||||
@@ -14,14 +13,9 @@ export const concert = Router()
|
||||
|
||||
concert.get("/concert/:id", (req: Request, res: Response) => {
|
||||
Concert.findByPk(req.params.id, {
|
||||
include: [
|
||||
include: [
|
||||
{
|
||||
model: Event,
|
||||
include: [
|
||||
{
|
||||
model: Band
|
||||
}
|
||||
]
|
||||
model: Band,
|
||||
},
|
||||
{
|
||||
model: Location,
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
import { Concert } from "../models/acts/concert.model";
|
||||
import { Band } from "../models/acts/band.model";
|
||||
import { Event } from "../models/acts/event.model";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { Location } from "../models/locations/location.model";
|
||||
import { Genre } from "../models/acts/genre.model";
|
||||
import { City } from "../models/locations/city.model";
|
||||
import { Op } from "sequelize";
|
||||
|
||||
export const events = Router()
|
||||
|
||||
events.get("/", async (req: Request, res: Response) => {
|
||||
let cityName = req.query.city
|
||||
let genreName = req.query.genre
|
||||
let sort = req.query.sort
|
||||
let count = req.query.count
|
||||
let cityFilter = {}
|
||||
let genreFilter = {}
|
||||
|
||||
if (cityName != undefined) {
|
||||
cityFilter = {
|
||||
model: City,
|
||||
where: { name: cityName }
|
||||
}
|
||||
} else {
|
||||
cityFilter = {
|
||||
model: City
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (genreName != undefined) {
|
||||
genreFilter = {
|
||||
model: Genre,
|
||||
where: { name: genreName }
|
||||
}
|
||||
} else {
|
||||
genreFilter = {
|
||||
model: Genre
|
||||
}
|
||||
}
|
||||
|
||||
Event.findAll({
|
||||
include: [
|
||||
{
|
||||
model: Concert,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
model: Location,
|
||||
required: true,
|
||||
include: [
|
||||
cityFilter
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
model: Band,
|
||||
required: true,
|
||||
include: [
|
||||
genreFilter
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
.then(events => {
|
||||
if (sort != undefined) {
|
||||
events.sort((event1, event2) => {
|
||||
if (sort == "desc") {
|
||||
return event2.dataValues.concerts.length - event1.dataValues.concerts.length
|
||||
} else if (sort == "asc") {
|
||||
return event1.dataValues.concerts.length - event2.dataValues.concerts.length
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (count != undefined) {
|
||||
events.splice(Number(count))
|
||||
}
|
||||
|
||||
res.status(200).json(events)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
// Event search
|
||||
events.get("/search", (req: Request, res: Response) => {
|
||||
Event.findAll({
|
||||
where: {
|
||||
name: {
|
||||
[Op.substring]: req.query.value
|
||||
}
|
||||
},
|
||||
include: [
|
||||
{
|
||||
model: Concert,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
model: Location,
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
model: Band,
|
||||
}
|
||||
]
|
||||
})
|
||||
.then(events => {
|
||||
res.status(200).json(events)
|
||||
})
|
||||
})
|
||||
@@ -2,7 +2,6 @@ import { Concert } from "../models/acts/concert.model";
|
||||
import { City } from "../models/locations/city.model";
|
||||
import { Location } from "../models/locations/location.model";
|
||||
import { Request, Response, Router } from "express";
|
||||
import { Event } from "../models/acts/event.model";
|
||||
import { Band } from "../models/acts/band.model";
|
||||
import { SeatGroup } from "../models/locations/seatGroup.model";
|
||||
import { Seat } from "../models/locations/seat.model";
|
||||
@@ -20,15 +19,7 @@ location.get("/", (req: Request, res: Response) => {
|
||||
City,
|
||||
{
|
||||
model: Concert,
|
||||
include: [
|
||||
{
|
||||
model: Event,
|
||||
include: [ Band ]
|
||||
}
|
||||
],
|
||||
attributes: {
|
||||
exclude: [ "locationId", "tourId" ]
|
||||
}
|
||||
include: [ Band ],
|
||||
},
|
||||
{
|
||||
model: SeatGroup,
|
||||
@@ -70,15 +61,7 @@ location.get("/location/:urlName", (req: Request, res: Response) => {
|
||||
City,
|
||||
{
|
||||
model: Concert,
|
||||
include: [
|
||||
{
|
||||
model: Event,
|
||||
include: [ Band ]
|
||||
}
|
||||
],
|
||||
attributes: {
|
||||
exclude: [ "locationId", "tourId" ]
|
||||
}
|
||||
include: [ Band ],
|
||||
},
|
||||
{
|
||||
model: SeatGroup,
|
||||
|
||||
@@ -6,7 +6,6 @@ import { Payment } from "../models/user/payment.model";
|
||||
import { Address } from "../models/user/address.model";
|
||||
import { Band } from "../models/acts/band.model";
|
||||
import { Location } from "../models/locations/location.model";
|
||||
import { Event } from "../models/acts/event.model";
|
||||
import { City } from "../models/locations/city.model";
|
||||
import { Seat } from "../models/locations/seat.model";
|
||||
import { SeatRow } from "../models/locations/seatRow.model";
|
||||
@@ -26,8 +25,7 @@ order.get("/:id", (req: Request, res: Response) => {
|
||||
model: Concert,
|
||||
include: [
|
||||
{
|
||||
model: Event,
|
||||
include: [ Band ]
|
||||
model: Band
|
||||
},
|
||||
{
|
||||
model: Location,
|
||||
|
||||
Reference in New Issue
Block a user