BOOM
This commit is contained in:
@@ -1,4 +1,11 @@
|
|||||||
use crate::models::{AutoIssuedTicket, IssuedTicket, NewTicket, Ticket};
|
use crate::{
|
||||||
|
models::{AutoIssuedTicket, IssuedTicket, NewTicket, Ticket},
|
||||||
|
schema::{
|
||||||
|
drivers,
|
||||||
|
issued_tickets::{self, driver},
|
||||||
|
tickets,
|
||||||
|
},
|
||||||
|
};
|
||||||
use common::CommonTicket;
|
use common::CommonTicket;
|
||||||
use diesel::prelude::*;
|
use diesel::prelude::*;
|
||||||
|
|
||||||
@@ -10,20 +17,30 @@ pub fn create_ticket(connection: &mut PgConnection, ticket: NewTicket) {
|
|||||||
.expect("Didn't save ticket AAAAAA");
|
.expect("Didn't save ticket AAAAAA");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_tickets(connection: &mut PgConnection, amount: i64) -> Vec<CommonTicket> {
|
pub fn get_tickets(connection: &mut PgConnection, driver_id: i32) -> Vec<CommonTicket> {
|
||||||
use crate::schema::tickets::dsl::*;
|
//Chonky join function for the sake of my life :))
|
||||||
let results = tickets
|
let join = tickets::table
|
||||||
.limit(amount)
|
.left_join(
|
||||||
.load::<Ticket>(connection)
|
issued_tickets::table.on(tickets::id
|
||||||
.expect("KANKER TIKET");
|
.eq(issued_tickets::ticket)
|
||||||
return results
|
.and(issued_tickets::driver.eq(driver_id))),
|
||||||
|
)
|
||||||
|
.select((
|
||||||
|
tickets::id,
|
||||||
|
tickets::category,
|
||||||
|
tickets::description,
|
||||||
|
tickets::issue_date, //only selecting the ticket tho :D
|
||||||
|
));
|
||||||
|
let tickets_by_driver = join.load::<Ticket>(connection).expect("oh no!");
|
||||||
|
let common_ticket_output = tickets_by_driver
|
||||||
.iter()
|
.iter()
|
||||||
.map(|ticket| CommonTicket {
|
.map(|ticket| CommonTicket {
|
||||||
id: ticket.id,
|
id: ticket.id,
|
||||||
category: String::from(&ticket.category),
|
category: String::from(&ticket.category),
|
||||||
description: String::from(&ticket.description),
|
description: String::from(&ticket.description),
|
||||||
})
|
})
|
||||||
.collect(); //Shoves everything to a vector
|
.collect();
|
||||||
|
return common_ticket_output;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_ticket(connection: &mut PgConnection, tickid: i32) -> CommonTicket {
|
pub fn get_ticket(connection: &mut PgConnection, tickid: i32) -> CommonTicket {
|
||||||
|
|||||||
@@ -204,9 +204,6 @@ function makeMutClosure(arg0, arg1, dtor, f) {
|
|||||||
|
|
||||||
return real;
|
return real;
|
||||||
}
|
}
|
||||||
function __wbg_adapter_18(arg0, arg1, arg2) {
|
|
||||||
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h414630ac9216cad4(arg0, arg1, addHeapObject(arg2));
|
|
||||||
}
|
|
||||||
|
|
||||||
let stack_pointer = 32;
|
let stack_pointer = 32;
|
||||||
|
|
||||||
@@ -215,7 +212,7 @@ function addBorrowedObject(obj) {
|
|||||||
heap[--stack_pointer] = obj;
|
heap[--stack_pointer] = obj;
|
||||||
return stack_pointer;
|
return stack_pointer;
|
||||||
}
|
}
|
||||||
function __wbg_adapter_21(arg0, arg1, arg2) {
|
function __wbg_adapter_18(arg0, arg1, arg2) {
|
||||||
try {
|
try {
|
||||||
wasm._dyn_core__ops__function__FnMut___A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h9380123c3ed0eddb(arg0, arg1, addBorrowedObject(arg2));
|
wasm._dyn_core__ops__function__FnMut___A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h9380123c3ed0eddb(arg0, arg1, addBorrowedObject(arg2));
|
||||||
} finally {
|
} finally {
|
||||||
@@ -223,6 +220,10 @@ function __wbg_adapter_21(arg0, arg1, arg2) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function __wbg_adapter_21(arg0, arg1, arg2) {
|
||||||
|
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h414630ac9216cad4(arg0, arg1, addHeapObject(arg2));
|
||||||
|
}
|
||||||
|
|
||||||
let cachedUint32Memory0 = new Uint32Array();
|
let cachedUint32Memory0 = new Uint32Array();
|
||||||
|
|
||||||
function getUint32Memory0() {
|
function getUint32Memory0() {
|
||||||
@@ -615,12 +616,12 @@ function getImports() {
|
|||||||
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
||||||
throw new Error(getStringFromWasm0(arg0, arg1));
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper4026 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper3831 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 272, __wbg_adapter_18);
|
const ret = makeMutClosure(arg0, arg1, 267, __wbg_adapter_18);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
imports.wbg.__wbindgen_closure_wrapper4088 = function(arg0, arg1, arg2) {
|
imports.wbg.__wbindgen_closure_wrapper6495 = function(arg0, arg1, arg2) {
|
||||||
const ret = makeMutClosure(arg0, arg1, 288, __wbg_adapter_21);
|
const ret = makeMutClosure(arg0, arg1, 294, __wbg_adapter_21);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -658,7 +659,7 @@ function initSync(module) {
|
|||||||
|
|
||||||
async function init(input) {
|
async function init(input) {
|
||||||
if (typeof input === 'undefined') {
|
if (typeof input === 'undefined') {
|
||||||
input = new URL('db-frontend-906e3d2c2bbb6313_bg.wasm', import.meta.url);
|
input = new URL('db-frontend-26b4e8491c3f6360_bg.wasm', import.meta.url);
|
||||||
}
|
}
|
||||||
const imports = getImports();
|
const imports = getImports();
|
||||||
|
|
||||||
Binary file not shown.
6
frontend/dist/index.html
vendored
6
frontend/dist/index.html
vendored
@@ -2,10 +2,10 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>Ze greatest</title>
|
<title>Ze greatest</title>
|
||||||
|
|
||||||
<link rel="preload" href="/db-frontend-906e3d2c2bbb6313_bg.wasm" as="fetch" type="application/wasm" crossorigin="">
|
<link rel="preload" href="/db-frontend-26b4e8491c3f6360_bg.wasm" as="fetch" type="application/wasm" crossorigin="">
|
||||||
<link rel="modulepreload" href="/db-frontend-906e3d2c2bbb6313.js"></head>
|
<link rel="modulepreload" href="/db-frontend-26b4e8491c3f6360.js"></head>
|
||||||
<body>
|
<body>
|
||||||
<script type="module">import init from '/db-frontend-906e3d2c2bbb6313.js';init('/db-frontend-906e3d2c2bbb6313_bg.wasm');</script><script>(function () {
|
<script type="module">import init from '/db-frontend-26b4e8491c3f6360.js';init('/db-frontend-26b4e8491c3f6360_bg.wasm');</script><script>(function () {
|
||||||
var protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
var protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||||
var url = protocol + '//' + window.location.host + '/_trunk/ws';
|
var url = protocol + '//' + window.location.host + '/_trunk/ws';
|
||||||
var poll_interval = 5000;
|
var poll_interval = 5000;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
mod driver_list;
|
|
||||||
mod fetching;
|
mod fetching;
|
||||||
use yew::prelude::*;
|
use yew::prelude::*;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
pub mod api;
|
pub mod api;
|
||||||
|
pub mod shadowrealmapi;
|
||||||
use crate::api::*;
|
use crate::api::*;
|
||||||
|
use crate::shadowrealmapi::*;
|
||||||
pub(crate) use actix_web::{App, HttpServer};
|
pub(crate) use actix_web::{App, HttpServer};
|
||||||
|
|
||||||
//Main function where all the api calls are
|
//Main function where all the api calls are
|
||||||
@@ -11,6 +13,9 @@ async fn main() -> std::io::Result<()> {
|
|||||||
.service(api_ticket)
|
.service(api_ticket)
|
||||||
.service(api_admin)
|
.service(api_admin)
|
||||||
.service(api_driver)
|
.service(api_driver)
|
||||||
|
.service(api_json_ticket)
|
||||||
|
.service(api_json_admin)
|
||||||
|
.service(api_json_driver)
|
||||||
.service(api_test)
|
.service(api_test)
|
||||||
})
|
})
|
||||||
.bind(("0.0.0.0", 48590))?
|
.bind(("0.0.0.0", 48590))?
|
||||||
|
|||||||
@@ -1,20 +1,38 @@
|
|||||||
|
use actix_web::{
|
||||||
|
get,
|
||||||
|
web::{self, Json},
|
||||||
|
};
|
||||||
|
use backend::{
|
||||||
|
admin_data::get_admin,
|
||||||
|
driver_data::get_driver,
|
||||||
|
establish_connection,
|
||||||
|
ticket_data::{get_ticket, get_tickets},
|
||||||
|
};
|
||||||
|
use common::{CommonAdmin, CommonDriver, CommonTicket};
|
||||||
|
|
||||||
// Json goodies? NAHH
|
// Json goodies? NAHH
|
||||||
// Ticket Table Services
|
// Ticket Table Services
|
||||||
// #[get("api/ticket/{id}")]
|
#[get("api/json/ticket/{id}")]
|
||||||
// async fn api_ticket(id: web::Path<i32>) -> Json<CommonTicket> {
|
async fn api_json_ticket(id: web::Path<i32>) -> Json<CommonTicket> {
|
||||||
// let fetched_ticket_data = get_ticket(&mut establish_connection(), *id);
|
let fetched_ticket_data = get_ticket(&mut establish_connection(), *id);
|
||||||
// Json(fetched_ticket_data)
|
Json(fetched_ticket_data)
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Getting admin data or smth idk
|
// Getting admin data or smth idk
|
||||||
// #[get("api/admin/{id}")]
|
#[get("api/json/admin/{id}")]
|
||||||
// async fn api_admin(id: web::Path<i32>) -> Json<CommonAdmin> {
|
async fn api_json_admin(id: web::Path<i32>) -> Json<CommonAdmin> {
|
||||||
// let fetched_admin_data = get_admin(&mut establish_connection(), *id);
|
let fetched_admin_data = get_admin(&mut establish_connection(), *id);
|
||||||
// Json(fetched_admin_data)
|
Json(fetched_admin_data)
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// #[get("api/driver/{id}")]
|
#[get("api/json/driver/{id}")]
|
||||||
// async fn api_driver(id: web::Path<i32>) -> Json<CommonDriver> {
|
async fn api_json_driver(id: web::Path<i32>) -> Json<CommonDriver> {
|
||||||
// let fetched_driver_data = get_driver(&mut establish_connection(), *id);
|
let fetched_driver_data = get_driver(&mut establish_connection(), *id);
|
||||||
// Json(fetched_driver_data)
|
Json(fetched_driver_data)
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
#[get("api/json/tickets/{driver}")]
|
||||||
|
async fn api_json_driver_tickets(id: web::Path<i32>) -> Json<Vec<CommonTicket>> {
|
||||||
|
let fetched_tickets = get_tickets(&mut establish_connection(), *id);
|
||||||
|
Json(fetched_tickets)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user