Fixes several big mistakes and finishes cherry picking
This commit is contained in:
parent
954f6a663b
commit
0d693eb299
|
|
@ -1 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="122" height="18" role="img" aria-label="test-coverage: 87%"><title>test-coverage: 87%</title><linearGradient id="bms-094034b04678331f" x2="0" y2="100%"><stop offset="0" stop-color="#fff" stop-opacity=".7"/><stop offset=".1" stop-color="#aaa" stop-opacity=".1"/><stop offset=".9" stop-color="#000" stop-opacity=".3"/><stop offset="1" stop-color="#000" stop-opacity=".5"/></linearGradient><clipPath id="bmr-094034b04678331f"><rect width="122" height="18" rx="4" fill="#fff"/></clipPath><g clip-path="url(#bmr-094034b04678331f)"><rect width="87" height="18" fill="#555"/><rect x="87" width="35" height="18" fill="#fe7d37"/><rect width="122" height="18" fill="url(#bms-094034b04678331f)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="445" y="140" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="770">test-coverage</text><text x="445" y="130" transform="scale(.1)" fill="#fff" textLength="770">test-coverage</text><text aria-hidden="true" x="1035" y="140" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">87%</text><text x="1035" y="130" transform="scale(.1)" fill="#fff" textLength="250">87%</text></g></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="122" height="18" role="img" aria-label="test-coverage: 84%"><title>test-coverage: 84%</title><linearGradient id="bms-c15e65abae712a1a" x2="0" y2="100%"><stop offset="0" stop-color="#fff" stop-opacity=".7"/><stop offset=".1" stop-color="#aaa" stop-opacity=".1"/><stop offset=".9" stop-color="#000" stop-opacity=".3"/><stop offset="1" stop-color="#000" stop-opacity=".5"/></linearGradient><clipPath id="bmr-c15e65abae712a1a"><rect width="122" height="18" rx="4" fill="#fff"/></clipPath><g clip-path="url(#bmr-c15e65abae712a1a)"><rect width="87" height="18" fill="#555"/><rect x="87" width="35" height="18" fill="#fe7d37"/><rect width="122" height="18" fill="url(#bms-c15e65abae712a1a)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="445" y="140" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="770">test-coverage</text><text x="445" y="130" transform="scale(.1)" fill="#fff" textLength="770">test-coverage</text><text aria-hidden="true" x="1035" y="140" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">84%</text><text x="1035" y="130" transform="scale(.1)" fill="#fff" textLength="250">84%</text></g></svg>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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<Mutex<ListPendingEvents>>,
|
||||
pub pending_events: Arc<std::sync::Mutex<ListPendingEvents>>,
|
||||
/// 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<Mutex<ListOngoingEvents>>,
|
||||
pub ongoing_events: Arc<std::sync::Mutex<ListOngoingEvents>>,
|
||||
/// 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<Mutex<ListClosedEvents>>,
|
||||
pub closed_events: Arc<std::sync::Mutex<ListClosedEvents>>,
|
||||
|
||||
/// A reference-counted pointer to a mutex-protected `NaiveDate` instance, representing the last date the watchdog was updated.
|
||||
pub old_date: Arc<Mutex<NaiveDate>>,
|
||||
pub old_date: Arc<std::sync::Mutex<NaiveDate>>,
|
||||
|
||||
/// The newly created discord context
|
||||
pub discord_ctx: Arc<Mutex<Option<poise::serenity_prelude::Context>>>,
|
||||
pub discord_ctx: Arc<tokio::sync::Mutex<Option<poise::serenity_prelude::Context>>>,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
///
|
||||
|
|
|
|||
Loading…
Reference in New Issue