WILL 100% WORK THIS TIME
This commit is contained in:
@@ -15,19 +15,15 @@ pub fn create_ticket(connection: &mut PgConnection, ticket: NewTicket) {
|
|||||||
|
|
||||||
pub fn get_tickets(connection: &mut PgConnection, driver_id: i32) -> Vec<CommonTicket> {
|
pub fn get_tickets(connection: &mut PgConnection, driver_id: i32) -> Vec<CommonTicket> {
|
||||||
//Chonky join function for the sake of my life :))
|
//Chonky join function for the sake of my life :))
|
||||||
let join = tickets::table.left_join(
|
let join = tickets::table
|
||||||
issued_tickets::table.on(tickets::id
|
.left_join(issued_tickets::table.on(issued_tickets::driver.eq(driver_id)))
|
||||||
.eq(issued_tickets::ticket)
|
.select((
|
||||||
.and(issued_tickets::driver.eq(driver_id))),
|
|
||||||
);
|
|
||||||
let queried_tickets = join.filter(issued_tickets::driver.eq(driver_id));
|
|
||||||
let queried_tickets = join.select((
|
|
||||||
tickets::id,
|
tickets::id,
|
||||||
tickets::category,
|
tickets::category,
|
||||||
tickets::description,
|
tickets::description,
|
||||||
tickets::issue_date,
|
tickets::issue_date,
|
||||||
)); //only selecting the ticket tho :D
|
));
|
||||||
let tickets_by_driver = queried_tickets.load::<Ticket>(connection).expect("oh no!");
|
let tickets_by_driver = join.load::<Ticket>(connection).expect("oh no!");
|
||||||
let common_ticket_output = tickets_by_driver
|
let common_ticket_output = tickets_by_driver
|
||||||
.iter()
|
.iter()
|
||||||
.map(|ticket| CommonTicket {
|
.map(|ticket| CommonTicket {
|
||||||
|
|||||||
Reference in New Issue
Block a user