Refactor models names

This commit is contained in:
Tobias Reisinger 2023-11-27 12:49:40 +01:00
parent 76b14ce75b
commit be7f31906c
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
24 changed files with 461 additions and 340 deletions
emgauwa-lib/src/handlers/v1/ws

View file

@ -1,4 +1,4 @@
use crate::db::Schedule;
use crate::db::DbSchedule;
use crate::handlers::errors::ApiError;
use actix::{Actor, StreamHandler};
use actix_web::{get, web, HttpRequest, HttpResponse};
@ -15,10 +15,10 @@ impl Actor for ControllerWs {
type Context = ws::WebsocketContext<Self>;
}
async fn get_schedules(pool: &mut Pool<Sqlite>) -> Result<Vec<Schedule>, ApiError> {
async fn get_schedules(pool: &mut Pool<Sqlite>) -> Result<Vec<DbSchedule>, ApiError> {
let mut pool_conn = pool.acquire().await?;
Ok(Schedule::get_all(&mut pool_conn).await?)
Ok(DbSchedule::get_all(&mut pool_conn).await?)
}
impl StreamHandler<Result<Message, ProtocolError>> for ControllerWs {
@ -28,9 +28,9 @@ impl StreamHandler<Result<Message, ProtocolError>> for ControllerWs {
match msg {
Ok(Message::Ping(msg)) => ctx.pong(&msg),
Ok(Message::Text(text)) => {
println!("Got text: {}", text.to_string());
println!("Got text: {}", text);
ctx.text(schedules_json)
},
}
_ => {}
}
}