From 04f7bcb012cc9f5319836747f16185dbeb8a23f0 Mon Sep 17 00:00:00 2001 From: Nuckal777 Date: Tue, 19 Nov 2024 21:29:48 +0100 Subject: [PATCH] Fix lints --- fastreach-api/src/main.rs | 10 +++++++--- fastreach-core/src/graph.rs | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/fastreach-api/src/main.rs b/fastreach-api/src/main.rs index dbf8381..1e216e5 100644 --- a/fastreach-api/src/main.rs +++ b/fastreach-api/src/main.rs @@ -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}, @@ -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> = reached.into_iter().map(|n| n.to_poly()).collect(); diff --git a/fastreach-core/src/graph.rs b/fastreach-core/src/graph.rs index b67bae7..83be18e 100644 --- a/fastreach-core/src/graph.rs +++ b/fastreach-core/src/graph.rs @@ -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 {