Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
fix: timeline bcs rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Bushuo committed Mar 2, 2024
1 parent 7555d8f commit ec5e929
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
13 changes: 7 additions & 6 deletions backend/src/controller/timeline.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
//! `Users` endpoints.
use crate::config::data::AppDataInner;
use crate::model::dto::timeline::TimelineParameters;
use crate::service;
use actix_web::{
get,
web::{Data, Path, Query},
web::{Path, Query},
HttpResponse, Result,
};

use crate::service;
use crate::{config::data::SharedPool, model::dto::timeline::TimelineParameters};

/// Get calculated timeline data for a given map from dates start to end.
/// The timeline contains all additions and removals of `Plantings` aggregated
/// by years, months, and also on the actual dates. It only contains years, months
Expand All @@ -33,12 +34,12 @@ use actix_web::{
pub async fn get_timeline(
map_id: Path<i32>,
parameters: Query<TimelineParameters>,
app_data: Data<AppDataInner>,
pool: SharedPool,
) -> Result<HttpResponse> {
let params = parameters.into_inner();
if params.start > params.end {
return Ok(HttpResponse::UnprocessableEntity().body("Start must be smaller than end"));
}
let dto = service::timeline::calculate(map_id.into_inner(), params, &app_data).await?;
let dto = service::timeline::calculate(map_id.into_inner(), params, &pool).await?;
Ok(HttpResponse::Ok().json(dto))
}
8 changes: 3 additions & 5 deletions backend/src/service/timeline.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use actix_web::web::Data;

use crate::{
config::data::AppDataInner,
config::data::SharedPool,
error::ServiceError,
model::{
dto::timeline::{TimelineDto, TimelineParameters},
Expand All @@ -17,9 +15,9 @@ use crate::{
pub async fn calculate(
map_id: i32,
params: TimelineParameters,
app_data: &Data<AppDataInner>,
pool: &SharedPool,
) -> Result<TimelineDto, ServiceError> {
let mut conn = app_data.pool.get().await?;
let mut conn = pool.get().await?;
// Check if the map exists
Map::find_by_id(map_id, &mut conn).await?;
let result = timeline::calculate(map_id, params, &mut conn).await?;
Expand Down

0 comments on commit ec5e929

Please sign in to comment.