max / goingson
| 1 | //! Named constants for the GoingsOn application. |
| 2 | //! |
| 3 | //! This module centralizes magic numbers and configuration values |
| 4 | //! to improve maintainability and documentation. |
| 5 | |
| 6 | // ============ Time Constants ============ |
| 7 | |
| 8 | /// Hours in a day. |
| 9 | pub const HOURS_PER_DAY: f64 = 24.0; |
| 10 | |
| 11 | /// Days in a week. |
| 12 | pub const DAYS_PER_WEEK: i64 = 7; |
| 13 | |
| 14 | /// Approximate days in a month (for relative date calculations). |
| 15 | pub const APPROXIMATE_DAYS_PER_MONTH: i64 = 30; |
| 16 | |
| 17 | // ============ Parser Defaults ============ |
| 18 | |
| 19 | /// Default hour for parsed dates (9:00 AM). |
| 20 | pub const DEFAULT_PARSE_HOUR: u32 = 9; |
| 21 | |
| 22 | /// Default minute for parsed dates. |
| 23 | pub const DEFAULT_PARSE_MINUTE: u32 = 0; |
| 24 | |
| 25 | // ============ Urgency Thresholds ============ |
| 26 | |
| 27 | /// Urgency score threshold for "high" classification (on a 0–10 scale). |
| 28 | /// Scores are computed by `calculate_urgency()` from priority, due date |
| 29 | /// proximity, task age, and tags. Tasks above 8.0 get the "urgency-high" |
| 30 | /// CSS class and sort to the top of the list. |
| 31 | pub const URGENCY_HIGH_THRESHOLD: f64 = 8.0; |
| 32 | |
| 33 | /// Urgency score threshold for "medium" classification (on the same 0–10 scale). |
| 34 | /// Tasks between 5.0 and 8.0 get "urgency-medium"; below 5.0 gets "urgency-low". |
| 35 | pub const URGENCY_MEDIUM_THRESHOLD: f64 = 5.0; |
| 36 | |
| 37 | // ============ Display Thresholds ============ |
| 38 | |
| 39 | /// Number of days for short-form due date display (e.g., "+3d" instead of "Mar 15"). |
| 40 | /// Used by `TaskResponse::from()` and `GoingsOn.utils.formatDue()` in the frontend |
| 41 | /// to decide between relative ("today", "+3d") and absolute ("Mar 15") formats. |
| 42 | pub const DAYS_THRESHOLD_SHORT_FORMAT: i64 = 7; |
| 43 | |
| 44 | // ============ Preview Lengths ============ |
| 45 | |
| 46 | /// Maximum length for email body preview snippets in the email list view. |
| 47 | /// Truncates the plain-text body to this many characters for the compact |
| 48 | /// thread listing, with an ellipsis appended if truncated. |
| 49 | pub const EMAIL_BODY_PREVIEW_LENGTH: usize = 100; |
| 50 | |
| 51 | // ============ Validation Limits ============ |
| 52 | |
| 53 | /// Maximum length for project names. |
| 54 | pub const MAX_PROJECT_NAME_LENGTH: usize = 255; |
| 55 | |
| 56 | /// Maximum length for task descriptions. |
| 57 | pub const MAX_TASK_DESCRIPTION_LENGTH: usize = 2000; |
| 58 | |
| 59 | /// Maximum length for event titles. |
| 60 | pub const MAX_EVENT_TITLE_LENGTH: usize = 255; |
| 61 | |
| 62 | /// Maximum length for contact display names. |
| 63 | pub const MAX_CONTACT_DISPLAY_NAME_LENGTH: usize = 255; |
| 64 | |
| 65 | /// Maximum scheduled duration in minutes (24 hours). |
| 66 | pub const MAX_SCHEDULED_DURATION_MINUTES: i32 = 24 * 60; |
| 67 | |
| 68 | /// Maximum relative date offset in days (~10 years). |
| 69 | pub const MAX_RELATIVE_DATE_DAYS: i64 = 3650; |
| 70 | |
| 71 | |
| 72 | |
| 73 | use *; |
| 74 | |
| 75 | |
| 76 | |
| 77 | const ; |
| 78 | const ; |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | assert_eq!; |
| 84 | |
| 85 | |
| 86 |