From 0d693eb299258b54db885097d2d531f7f906d8bc Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Fri, 29 Nov 2024 19:00:38 +0100 Subject: [PATCH] Fixes several big mistakes and finishes cherry picking --- badges/coverage.svg | 2 +- src/date/date_tools.rs | 11 ++++++++--- src/io.rs | 2 +- src/votes/helper_functions.rs | 12 ++++++------ src/watchdog.rs | 2 +- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/badges/coverage.svg b/badges/coverage.svg index afa3526..ead59f4 100644 --- a/badges/coverage.svg +++ b/badges/coverage.svg @@ -1 +1 @@ -test-coverage: 87%test-coverage87% +test-coverage: 84%test-coverage84% diff --git a/src/date/date_tools.rs b/src/date/date_tools.rs index 32c04c2..ab6a8b3 100644 --- a/src/date/date_tools.rs +++ b/src/date/date_tools.rs @@ -2,6 +2,7 @@ use crate::{date::date_parse::parse_simple_date, error_handling::IdleError}; use chrono::{Datelike, Duration, Local, Month, Months, NaiveDate, Weekday}; +use log::error; use serde::{Deserialize, Serialize}; use super::{ @@ -79,6 +80,8 @@ pub fn relative_date_to_date( .ok_or(IdleError::InvalidDate), Some(m) => context .checked_add_months(Months::new(12)) + // TODO: THIS IS AN INDICATOR OF A BIGGER MISTAKE + .and_then(|d| d.with_day(day)) .and_then(|d| d.with_month(m.number_from_month())) .ok_or(IdleError::InvalidDate), None if day >= context.day() => Ok(context), @@ -89,7 +92,11 @@ pub fn relative_date_to_date( Ok(new_base) => new_base .with_day(day) .ok_or(IdleError::InvalidDate(day, month)), - Err(_) => Err(IdleError::InvalidDate(day, month)), + Err(_) => { + error!("Logged an error"); + println!("EH"); + Err(IdleError::InvalidDate(day, month)) + } } } @@ -114,14 +121,12 @@ impl DatePoint { /// ``` ///use chrono::{Local, Month}; ///use idlefox::date::date_parse::{DateObject, DatePoint}; - ///let today = Local::now().date_naive(); ///let date_point = DatePoint::Date { /// day: 14, /// month: Some(Month::February), ///}; ///let next_valid_date_object = DateObject::Single(date_point); - ///let naive_date = next_valid_date_object /// .to_naive_date_object(Some(today)) /// .unwrap(); diff --git a/src/io.rs b/src/io.rs index 5932287..46c6205 100644 --- a/src/io.rs +++ b/src/io.rs @@ -193,7 +193,7 @@ pub async fn vote_modal( title: underlying_data.title, description: underlying_data.description, group, - hours: underlying_data.hours, + // hours: underlying_data.hours, identifier: VoteTypeIdentifier::WeeklyVote, ..Default::default() }; diff --git a/src/votes/helper_functions.rs b/src/votes/helper_functions.rs index c9ca663..5509d76 100644 --- a/src/votes/helper_functions.rs +++ b/src/votes/helper_functions.rs @@ -1,6 +1,6 @@ //! Submodule including all helper functions to handle vote creation and evolution //! -use std::sync::{Arc, Mutex}; +use std::sync::Arc; use chrono::NaiveDate; use uuid::Uuid; @@ -180,20 +180,20 @@ pub struct EventHolder { /// A reference-counted pointer to a mutex-protected `PendingEvents` instance, managing all pending events. /// /// Pending events are those that have been scheduled but not yet started - pub pending_events: Arc>, + pub pending_events: Arc>, /// A reference-counted pointer to a mutex-protected `OngoingEvents` instance, managing all ongoing events. /// /// Ongoing events are currently running but not yet closed. - pub ongoing_events: Arc>, + pub ongoing_events: Arc>, /// A reference-counted pointer to a mutex-protected `OngoingEvents` instance, managing all closed events. /// /// Closed events have been voted up but havent been deleted and can therefore be watched or opened again. /// These events will be autodeleted after a while - pub closed_events: Arc>, + pub closed_events: Arc>, /// A reference-counted pointer to a mutex-protected `NaiveDate` instance, representing the last date the watchdog was updated. - pub old_date: Arc>, + pub old_date: Arc>, /// The newly created discord context - pub discord_ctx: Arc>>, + pub discord_ctx: Arc>>, } diff --git a/src/watchdog.rs b/src/watchdog.rs index 0c13eab..40946c7 100644 --- a/src/watchdog.rs +++ b/src/watchdog.rs @@ -15,7 +15,7 @@ use crate::votes::EventHolder; use chrono::{DateTime, Local, NaiveDate}; -use poise::serenity_prelude::{self, CacheHttp, ChannelId, Message}; +use poise::serenity_prelude::{self, CacheHttp, ChannelId}; /// The main scheduler waiting and dispatch loop. ///