simple clean up
This commit is contained in:
parent
36b60cd298
commit
f12ed610d7
18
src/main.rs
18
src/main.rs
@ -1,12 +1,10 @@
|
|||||||
use std::sync::Mutex;
|
|
||||||
|
|
||||||
use axum::{
|
use axum::{
|
||||||
response::IntoResponse,
|
response::IntoResponse,
|
||||||
routing::{delete, get, put},
|
routing::{delete, get, put},
|
||||||
Extension, Router,
|
Extension, Router,
|
||||||
};
|
};
|
||||||
use polars::prelude::*;
|
use polars::prelude::*;
|
||||||
use tokio_postgres::NoTls;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
// Generetes a bunch of random data in the db
|
// Generetes a bunch of random data in the db
|
||||||
async fn generate_random_data(
|
async fn generate_random_data(
|
||||||
@ -198,17 +196,19 @@ async fn get_data(
|
|||||||
|
|
||||||
async fn accounts(Extension(state): Extension<Arc<State>>) -> impl IntoResponse {
|
async fn accounts(Extension(state): Extension<Arc<State>>) -> impl IntoResponse {
|
||||||
let accounts = state.accounts_dataframe.lock().unwrap();
|
let accounts = state.accounts_dataframe.lock().unwrap();
|
||||||
if accounts.is_some() {
|
if accounts.is_none() {
|
||||||
|
return "Injest Data First".into();
|
||||||
|
}
|
||||||
let df = accounts.as_ref().unwrap().clone();
|
let df = accounts.as_ref().unwrap().clone();
|
||||||
let to_send = df.select(vec![col("uuid"), col("name")]).collect().unwrap();
|
let to_send = df.select(vec![col("uuid"), col("name")]).collect().unwrap();
|
||||||
return format!("{}", to_send);
|
return format!("{}", to_send);
|
||||||
}
|
|
||||||
return "Injest Data First".into();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn transactions(Extension(state): Extension<Arc<State>>) -> impl IntoResponse {
|
async fn transactions(Extension(state): Extension<Arc<State>>) -> impl IntoResponse {
|
||||||
let transactions = state.transactions_dataframe.lock().unwrap();
|
let transactions = state.transactions_dataframe.lock().unwrap();
|
||||||
if transactions.is_some() {
|
if transactions.is_none() {
|
||||||
|
return "Injest Data First".into();
|
||||||
|
}
|
||||||
let df = transactions.as_ref().unwrap().clone();
|
let df = transactions.as_ref().unwrap().clone();
|
||||||
let to_send = df
|
let to_send = df
|
||||||
.select(vec![
|
.select(vec![
|
||||||
@ -220,8 +220,6 @@ async fn transactions(Extension(state): Extension<Arc<State>>) -> impl IntoRespo
|
|||||||
.collect()
|
.collect()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
return format!("{}", to_send);
|
return format!("{}", to_send);
|
||||||
}
|
|
||||||
return "Injest Data First".into();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct State {
|
struct State {
|
||||||
@ -246,7 +244,7 @@ async fn main() {
|
|||||||
}
|
}
|
||||||
let psql_conn = psql_conn.unwrap();
|
let psql_conn = psql_conn.unwrap();
|
||||||
|
|
||||||
let (client, connection) = tokio_postgres::connect(psql_conn.as_str(), NoTls)
|
let (client, connection) = tokio_postgres::connect(psql_conn.as_str(), tokio_postgres::NoTls)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user