This commit is contained in:
LinlyBoi
2022-12-26 00:04:10 +02:00
parent 598718f9d8
commit c93bb7ad17

View File

@@ -16,13 +16,14 @@ 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 let join = tickets::table
.left_join(issued_tickets::table.on(issued_tickets::driver.eq(driver_id))) .left_join(issued_tickets::table)
.select(( .select((
tickets::id, tickets::id,
tickets::category, tickets::category,
tickets::description, tickets::description,
tickets::issue_date, tickets::issue_date,
)); ))
.filter(issued_tickets::driver.eq(driver_id));
let tickets_by_driver = join.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()