only show future shifts

This commit is contained in:
Pierre de Lacroix 2026-06-29 16:03:00 +02:00
parent 42a4107162
commit ea2cfa4bea
Signed by: lateralus23
GPG key ID: 53E0CEC29C24EF39

View file

@ -1,5 +1,5 @@
use crate::grist::{Priority, Shift};
use chrono::{DateTime, FixedOffset, TimeZone};
use chrono::{DateTime, FixedOffset, TimeZone, Utc};
use clap::{CommandFactory, Parser, Subcommand};
use matrix_sdk::{Client, Room};
@ -102,7 +102,16 @@ pub async fn handle(command: impl AsRef<str>, room: Room, client: Client) -> Res
match clap.action {
Action::List => {
debug!("user asked for list");
let shifts = crate::grist::list_shifts().await?;
let shifts = crate::grist::list_shifts()
.await?
.into_iter()
.filter(|shift| {
let now = Utc::now().with_timezone(
&FixedOffset::east_opt(2 * 3600).expect("failed to local time 1"),
);
shift.start_time >= now
})
.collect();
debug!("{:?}", shifts);
send_room_msg_html(client, room, format_shifts(shifts)).await?;
}