Skip to content

Commit

Permalink
Fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuckal777 committed Nov 19, 2024
1 parent cf3d361 commit 04f7bcb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions fastreach-api/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{fs::File, sync::Arc};

use chrono::{Duration, NaiveDateTime};
use chrono::{DateTime, Duration};
use fastreach_core::{
cascade,
graph::{Graph, IsochroneDijsktra},
Expand Down Expand Up @@ -66,11 +66,15 @@ impl<'a> IsochroneHandler<'a> {
.ids
.get(&id)
.ok_or(HandlerError::BadRequest("station not found".to_owned()))?;
let start_time = NaiveDateTime::from_timestamp_millis(body.start)
let start_time = DateTime::from_timestamp_millis(body.start)
.ok_or(HandlerError::BadRequest("invalid start time".to_owned()))?;
let mut algo = IsochroneDijsktra::new(&self.graph);
let reached = algo
.nodes_within(*start_idx, start_time, Duration::minutes(body.minutes))
.nodes_within(
*start_idx,
start_time.naive_utc(),
Duration::minutes(body.minutes),
)
.map_err(|_| HandlerError::InternalServerError("failed dijsktra".to_owned()))?;

let polys: Vec<Polygon<f32>> = reached.into_iter().map(|n| n.to_poly()).collect();
Expand Down
2 changes: 1 addition & 1 deletion fastreach-core/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ impl<'a, 'b: 'a> IsochroneDijsktra<'a, 'b> {
let year = number & 0b_0000_0000_0111_1111;
let month = (number >> 7) & 0b_0000_0000_0000_1111;
let day = (number >> 11) & 0b_0000_0000_0001_1111;
NaiveDate::from_ymd_opt(year as i32 + 2000, month.into(), day.into()).unwrap()
NaiveDate::from_ymd_opt(i32::from(year) + 2000, month.into(), day.into()).unwrap()
}

fn valid_on(period: &OperatingPeriod<'b>, date: NaiveDate) -> Result<bool, Error> {
Expand Down

0 comments on commit 04f7bcb

Please sign in to comment.