Cargo update
This commit is contained in:
11
src/db.rs
11
src/db.rs
@@ -1,4 +1,4 @@
|
||||
use chrono::{DateTime, NaiveDateTime, TimeZone, Utc};
|
||||
use chrono::{DateTime, TimeZone, Utc};
|
||||
use diesel::Queryable;
|
||||
|
||||
use crate::appointment::Appointment;
|
||||
@@ -31,18 +31,13 @@ impl From<DbChat> for ChatInfo<Utc> {
|
||||
// Join appointments into single option
|
||||
.and_then(|start| Some([start, db_chat.next_appointment_end?]))
|
||||
// Convert timestamps to datetimes
|
||||
.map(|timestamps| {
|
||||
timestamps
|
||||
.map(|timestamp| NaiveDateTime::from_timestamp_opt(timestamp, 0).unwrap())
|
||||
.map(|date_time| DateTime::<Utc>::from_utc(date_time, Utc))
|
||||
})
|
||||
.map(|timestamps| timestamps.map(|timestamp| Utc.timestamp_opt(timestamp, 0).unwrap()))
|
||||
// Join datetimes into Appointment
|
||||
.map(|[start, end]| Appointment { start, end });
|
||||
|
||||
let last_reminder = db_chat
|
||||
.last_reminder
|
||||
.map(|timestamp| NaiveDateTime::from_timestamp_opt(timestamp, 0).unwrap())
|
||||
.map(|date_time| DateTime::<Utc>::from_utc(date_time, Utc));
|
||||
.map(|timestamp| Utc.timestamp_opt(timestamp, 0).unwrap());
|
||||
|
||||
let locale = db_chat.locale.unwrap_or("de".into());
|
||||
|
||||
|
||||
@@ -105,8 +105,7 @@ async fn main() {
|
||||
};
|
||||
|
||||
let sleep_duration = next_appointment
|
||||
.map(|timestamp| NaiveDateTime::from_timestamp_opt(timestamp, 0).unwrap())
|
||||
.map(|naive_date_time| DateTime::<Utc>::from_utc(naive_date_time, Utc))
|
||||
.map(|timestamp| Utc.timestamp_opt(timestamp, 0).unwrap())
|
||||
.map(|date_time| date_time - now)
|
||||
.map(|duration| duration.to_std().unwrap())
|
||||
.filter(|duration| *duration < poll_duration)
|
||||
|
||||
Reference in New Issue
Block a user