From 0d9b3e8209953f1a676d16b44055406e446c0d01 Mon Sep 17 00:00:00 2001 From: keinsell Date: Sun, 2 Feb 2025 21:12:48 +0100 Subject: [PATCH] remove unused `journal` module --- TASK.md | 159 ------------------------------------ src/analyzer/model.rs | 10 +-- src/analyzer/service.rs | 21 ----- src/journal/README.md | 7 -- src/journal/mod.rs | 19 ----- src/main.rs | 3 +- src/substance/repository.rs | 2 +- 7 files changed, 3 insertions(+), 218 deletions(-) delete mode 100644 TASK.md delete mode 100644 src/journal/README.md delete mode 100644 src/journal/mod.rs diff --git a/TASK.md b/TASK.md deleted file mode 100644 index f959b213..00000000 --- a/TASK.md +++ /dev/null @@ -1,159 +0,0 @@ -# Journal Implementation Plan - -## Overview -The journal functionality will serve as a calendar-like system that tracks and displays phases from user ingestions. Unlike traditional calendars, this system needs to handle events (phases) with uncertain start and end times, making it more complex than standard calendar implementations. - -## Core Components - -### 1. Journal Entity -```rust -struct JournalEntry { - id: i32, - ingestion_id: i32, - phase_id: String, - expected_start_time: DateTime, - expected_end_time: Option>, - confidence_start: f32, // 0.0-1.0 representing certainty of start time - confidence_end: f32, // 0.0-1.0 representing certainty of end time - actual_start_time: Option>, - actual_end_time: Option>, - status: PhaseStatus, - metadata: Json, // Additional phase-specific data - created_at: DateTime, - updated_at: DateTime, -} -``` - -### 2. Event Handling System -- Create event handlers for `IngestionCreated` -- Automatically generate phase entries when new ingestions are created -- Update journal entries as phases progress -- Handle phase transitions and completion states - -### 3. Time Uncertainty Management -- Implement confidence scoring system for start/end times -- Use substance-specific metabolism data to estimate phase durations -- Account for individual user variations and conditions -- Provide visual indicators for time uncertainty in UI - -## Implementation Steps - -1. Database Schema - - Create journal entries table - - Add foreign key relationships to ingestions - - Add indices for efficient time-based queries - -2. Core Logic - - Implement phase calculation system - - Create event handlers for ingestion creation - - Develop time uncertainty algorithms - - Build phase transition logic - -3. Query System - - Create efficient queries for time ranges - - Implement filtering by confidence levels - - Add support for phase-specific queries - - Build aggregation queries for analysis - -4. API/CLI Interface - - Add journal-specific commands - - Implement time range queries - - Create phase filtering options - - Add export capabilities - -5. UI Components - - Design calendar view with uncertainty visualization - - Implement phase timeline display - - Add filtering and search interface - - Create detailed phase view - -## Technical Considerations - -### Database Migrations -```sql -CREATE TABLE journal_entry ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - ingestion_id INTEGER NOT NULL, - phase_id TEXT NOT NULL, - expected_start_time TIMESTAMP NOT NULL, - expected_end_time TIMESTAMP, - confidence_start REAL NOT NULL, - confidence_end REAL NOT NULL, - actual_start_time TIMESTAMP, - actual_end_time TIMESTAMP, - status TEXT NOT NULL, - metadata JSON NOT NULL, - created_at TIMESTAMP NOT NULL, - updated_at TIMESTAMP NOT NULL, - FOREIGN KEY (ingestion_id) REFERENCES ingestion(id) -); - -CREATE INDEX idx_journal_entry_times ON journal_entry(expected_start_time, expected_end_time); -CREATE INDEX idx_journal_entry_ingestion ON journal_entry(ingestion_id); -``` - -### Event System Integration -```rust -// Event handler for new ingestions -async fn handle_ingestion_created(event: IngestionCreated) -> Result<()> { - let phases = calculate_phases_for_ingestion(event.ingestion_id).await?; - - for phase in phases { - create_journal_entry(JournalEntry { - ingestion_id: event.ingestion_id, - phase_id: phase.id, - expected_start_time: phase.estimated_start, - expected_end_time: phase.estimated_end, - confidence_start: calculate_start_confidence(&phase), - confidence_end: calculate_end_confidence(&phase), - status: PhaseStatus::Pending, - // ... other fields - }).await?; - } - Ok(()) -} -``` - -## Future Enhancements - -1. Machine Learning Integration - - Train models on user data to improve time predictions - - Develop personalized confidence scoring - - Implement pattern recognition for phase transitions - -2. Advanced Visualization - - Heat maps for time uncertainty - - Phase overlap visualization - - Interactive timeline adjustments - -3. Integration Features - - Calendar export (iCal format) - - Mobile app synchronization - - External API access - -4. Analysis Tools - - Phase pattern analysis - - Substance interaction tracking - - Long-term trend visualization - -## Success Criteria - -1. Accurate Phase Tracking - - Correctly generate phases for new ingestions - - Accurate time predictions within confidence bounds - - Proper handling of phase transitions - -2. Performance - - Fast query response times (< 100ms) - - Efficient handling of large datasets - - Minimal impact on ingestion creation - -3. Usability - - Intuitive calendar interface - - Clear visualization of uncertainty - - Easy filtering and search capabilities - -4. Reliability - - Consistent phase calculations - - Proper error handling - - Data integrity maintenance \ No newline at end of file diff --git a/src/analyzer/model.rs b/src/analyzer/model.rs index c72c09b3..7dcb3920 100644 --- a/src/analyzer/model.rs +++ b/src/analyzer/model.rs @@ -55,12 +55,4 @@ pub struct IngestionPhase pub(crate) duration_range: Range, pub(crate) prev: Option>, pub(crate) next: Option>, -} - -/// !TODO -/// `JournalAnalysis` is a struct that represents the analytics of a complete -/// user's ingestion history it contains a various aspects of information, such -/// as classification by psychoactive groups, peeking into recommended dosages -/// and history of usage, pattern recognition and statically defined rule engine -/// to inform user again stupid decisions they are about to make. -pub struct JournalAnalysis {} +} \ No newline at end of file diff --git a/src/analyzer/service.rs b/src/analyzer/service.rs index 42818e2c..76ebbee8 100644 --- a/src/analyzer/service.rs +++ b/src/analyzer/service.rs @@ -104,25 +104,4 @@ impl IngestionAnalysis phases, }) } - - /// The progress of the ingestion event, represented as a float between 0.0 - /// and 1.0. This value represents the fraction of the total duration - /// (excluding the afterglow phase) that has elapsed. - pub fn progress(&self) -> f64 - { - let now = chrono::Local::now(); - let total_duration = self.ingestion_end - self.ingestion_start; - let elapsed_time = if now < self.ingestion_start - { - chrono::Duration::zero() - } - else - { - (now - self.ingestion_start).min(total_duration) - }; - - (elapsed_time.num_seconds() as f64 / total_duration.num_seconds() as f64).clamp(0.0, 1.0) - } - - } diff --git a/src/journal/README.md b/src/journal/README.md deleted file mode 100644 index 2fadbc3e..00000000 --- a/src/journal/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Journal - -Journal is a functionality which combine ingestion logs, substance information and calendar into one place, it allows -user to track what's currently active and show future events. - -- [ ] Develop a database model which will be storing phases analyzed with analyzer -- [ ] Build CalDAV compatible calendar in database \ No newline at end of file diff --git a/src/journal/mod.rs b/src/journal/mod.rs deleted file mode 100644 index dc8e7a44..00000000 --- a/src/journal/mod.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::substance::route_of_administration::phase::PhaseClassification; -use chrono::DateTime; -use chrono::Local; - -/// !todo Journal is about combining user's inputs against their neurochemical, -/// user is able to take "checkpoints" on their timeline and note how they feel -/// at that time. This functionality fundamentally allow for correlation of -/// ingestion with real-life mood and subjective experience and with enough data -/// collected sufficient probability could be established so user will be -/// informed what had potentially good subjective impact on them and what had -/// potentially bad. -struct Journal -{ - id: Option, - from: DateTime, - to: DateTime, - phase_classification: PhaseClassification, - ingestion_id: i32, -} diff --git a/src/main.rs b/src/main.rs index 00e605f0..a4daee48 100755 --- a/src/main.rs +++ b/src/main.rs @@ -19,8 +19,7 @@ mod analyzer; mod cli; mod core; mod database; -pub mod ingestion; -mod journal; +mod ingestion; mod prelude; mod substance; mod tui; diff --git a/src/substance/repository.rs b/src/substance/repository.rs index ee577908..682ac6ec 100755 --- a/src/substance/repository.rs +++ b/src/substance/repository.rs @@ -24,7 +24,7 @@ use std::str::FromStr; #[io_cached( disk = true, - sync_to_disk_on_cache_change = true, + sync_to_disk_on_cache_change = false, map_error = r##"|e| SubstanceError::DiskError"##, time = 2592000000 )]