//! Named constants for the GoingsOn application. //! //! This module centralizes magic numbers and configuration values //! to improve maintainability and documentation. // ============ Time Constants ============ /// Hours in a day. pub const HOURS_PER_DAY: f64 = 24.0; /// Days in a week. pub const DAYS_PER_WEEK: i64 = 7; /// Approximate days in a month (for relative date calculations). pub const APPROXIMATE_DAYS_PER_MONTH: i64 = 30; // ============ Parser Defaults ============ /// Default hour for parsed dates (9:00 AM). pub const DEFAULT_PARSE_HOUR: u32 = 9; /// Default minute for parsed dates. pub const DEFAULT_PARSE_MINUTE: u32 = 0; // ============ Urgency Thresholds ============ /// Urgency score threshold for "high" classification (on a 0–10 scale). /// Scores are computed by `calculate_urgency()` from priority, due date /// proximity, task age, and tags. Tasks above 8.0 get the "urgency-high" /// CSS class and sort to the top of the list. pub const URGENCY_HIGH_THRESHOLD: f64 = 8.0; /// Urgency score threshold for "medium" classification (on the same 0–10 scale). /// Tasks between 5.0 and 8.0 get "urgency-medium"; below 5.0 gets "urgency-low". pub const URGENCY_MEDIUM_THRESHOLD: f64 = 5.0; // ============ Display Thresholds ============ /// Number of days for short-form due date display (e.g., "+3d" instead of "Mar 15"). /// Used by `TaskResponse::from()` and `GoingsOn.utils.formatDue()` in the frontend /// to decide between relative ("today", "+3d") and absolute ("Mar 15") formats. pub const DAYS_THRESHOLD_SHORT_FORMAT: i64 = 7; // ============ Preview Lengths ============ /// Maximum length for email body preview snippets in the email list view. /// Truncates the plain-text body to this many characters for the compact /// thread listing, with an ellipsis appended if truncated. pub const EMAIL_BODY_PREVIEW_LENGTH: usize = 100; // ============ Validation Limits ============ /// Maximum length for project names. pub const MAX_PROJECT_NAME_LENGTH: usize = 255; /// Maximum length for task descriptions. pub const MAX_TASK_DESCRIPTION_LENGTH: usize = 2000; /// Maximum length for event titles. pub const MAX_EVENT_TITLE_LENGTH: usize = 255; /// Maximum length for contact display names. pub const MAX_CONTACT_DISPLAY_NAME_LENGTH: usize = 255; /// Maximum scheduled duration in minutes (24 hours). pub const MAX_SCHEDULED_DURATION_MINUTES: i32 = 24 * 60; /// Maximum relative date offset in days (~10 years). pub const MAX_RELATIVE_DATE_DAYS: i64 = 3650; #[cfg(test)] mod tests { use super::*; #[test] fn urgency_thresholds_are_ordered() { const { assert!(URGENCY_HIGH_THRESHOLD > URGENCY_MEDIUM_THRESHOLD) }; const { assert!(URGENCY_MEDIUM_THRESHOLD > 0.0) }; } #[test] fn max_scheduled_duration_is_24_hours() { assert_eq!(MAX_SCHEDULED_DURATION_MINUTES, 1440); } }