no more warnings + debug

This commit is contained in:
LinlyBoi
2023-12-17 23:57:26 +02:00
parent 341bb51fdb
commit 8edbc7e61d
2 changed files with 9 additions and 10 deletions

View File

@@ -4,14 +4,14 @@ pub fn init_arrivals_scope() -> actix_web::Scope {
let scope = web::scope("/arrivals").service(show_arrivals);
scope
}
use chrono::NaiveDateTime;
use chrono::NaiveTime;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub struct Arrival {
a_id: u32,
time_of_day: NaiveDateTime,
week_day: u32,
tram_line: u32,
a_id: i32,
time_of_day: NaiveTime,
week_day: i32,
tram_line: i32,
direction: bool,
}
use web::Data;
@@ -19,11 +19,10 @@ use sqlx::{PgPool, query_as};
#[get("arrivals")]
async fn show_arrivals(db_pool: Data<PgPool>) -> impl Responder {
let arrivals = query_as!(Arrival, r#"SELECT * FROM arrivals"#)
.fetch_all(db_pool)
.fetch_all(db_pool.get_ref())
.await
.expect("Could not fetch arrivals");
HttpResponse::Ok()
.content_type("application/json")
.json(arrivals);
todo!()
.json(arrivals)
}

View File

@@ -1,4 +1,4 @@
use actix_web::{get, post, web, App, HttpResponse, HttpServer, Responder};
use actix_web::{post, web, App, HttpResponse, HttpServer, Responder};
use dotenv::dotenv;
use witl_api::*;
#[post("/echo")]
@@ -10,7 +10,7 @@ mod arrivals;
#[actix_web::main]
async fn main() -> std::io::Result<()> {
dotenv().ok();
let (port, address) = init_address();
std::env::set_var("RUST_LOG", "debug");
HttpServer::new(|| {
App::new()
.service(echo)