From 98568e38e2186f00cb136e844fdb56158636a542 Mon Sep 17 00:00:00 2001 From: Mitchell Marino Date: Sun, 16 Apr 2023 00:07:18 -0500 Subject: [PATCH] fixed get_previous_events endpoint --- Cargo.toml | 1 - src/events.rs | 78 +++++++++++++++++++++++++-------------------------- src/report.rs | 8 +----- 3 files changed, 40 insertions(+), 47 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1588248..c0417af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,5 +17,4 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] } sha256 = "1.1" jsonwebtoken = "8.3" tera = "1" -genpdf = "0.2" lazy_static = "1.4" diff --git a/src/events.rs b/src/events.rs index 0f16685..2606240 100644 --- a/src/events.rs +++ b/src/events.rs @@ -26,25 +26,25 @@ pub async fn get_events_preview( let result = query_as!( Event, r#" -SELECT - id, - title, - description, - time_start, - time_end, - event_type AS "event_type!: EventType", - points, - place, - price, - created_by -FROM - events -WHERE - time_start BETWEEN now() AND now() + interval '1 week' -ORDER BY - time_start -LIMIT - 10; + SELECT + id, + title, + description, + time_start, + time_end, + event_type AS "event_type!: EventType", + points, + place, + price, + created_by + FROM + events + WHERE + time_start BETWEEN now() AND now() + interval '1 week' + ORDER BY + time_start + LIMIT + 10; "# ) .fetch_all(&app_state.db_pool) @@ -74,25 +74,25 @@ pub async fn get_all_events( let result = query_as!( Event, r#" -SELECT - id, - title, - description, - time_start, - time_end, - event_type AS "event_type!: EventType", - points, - place, - price, - created_by -FROM - events -WHERE - time_start > now() -ORDER BY - time_start -LIMIT - 100; + SELECT + id, + title, + description, + time_start, + time_end, + event_type AS "event_type!: EventType", + points, + place, + price, + created_by + FROM + events + WHERE + time_start > now() + ORDER BY + time_start + LIMIT + 100; "# ) .fetch_all(&app_state.db_pool) @@ -135,7 +135,7 @@ pub async fn get_recent_events( e.created_by FROM events e INNER JOIN event_attendees ea - ON ea.event_id = e.id + ON ea.event_id = e.id AND ea.confirmed WHERE ea.user_id = $1 ; diff --git a/src/report.rs b/src/report.rs index e489c67..ad4e97b 100644 --- a/src/report.rs +++ b/src/report.rs @@ -10,12 +10,6 @@ use axum::{ Json, }; use axum_auth::AuthBearer; -use genpdf::{ - elements::{self, TableLayout}, - fonts::{self, FontFamily}, - style::{Style, StyledString}, - Document, -}; use lazy_static::lazy_static; use serde_json::json; use sqlx::{query_as, types::chrono::Local}; @@ -98,5 +92,5 @@ pub async fn get_report( } }; - (StatusCode::OK, Json(json!({ "report": report }))).into_response() + (StatusCode::OK, report).into_response() }