Skip to content

Commit

Permalink
Fix exercise API
Browse files Browse the repository at this point in the history
  • Loading branch information
bennekrouf committed Jan 19, 2024
1 parent c6a5876 commit f64d0a4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/api/generate_exercise_endpoint.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
use rocket::{get, State};
use rocket::serde::json::Json;

use crate::xhr_guard::XHR;
use crate::models::{Database, Exercise};
use crate::domain::exercise::get_exercises::get_exercises;
use crate::utils::parse_ranges::parse_ranges;

#[get("/exercise_list?<ranges>")]
pub fn generate_exercise_list_endpoint(ranges: Option<String>, dbs: &State<Database>, _xhr: XHR) -> Json<Vec<Exercise>> {
pub fn generate_exercise_list_endpoint(
dbs: &State<Database>,
ranges: Option<String> ,
) -> Json<Vec<Exercise>> {
let parsed_ranges = ranges.as_ref().map(|r| parse_ranges(r));
let exercises = get_exercises(&dbs, &parsed_ranges);
Json(exercises)
Expand Down

0 comments on commit f64d0a4

Please sign in to comment.