1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
//! Database layer for the kasl application.
//!
//! Provides a complete data persistence layer built on SQLite, offering type-safe
//! database operations for all application entities. Implements a migration system
//! for schema evolution and provides specialized modules for different data types.
//!
//! ## Features
//!
//! - **Core Infrastructure**: Connection management and migrations
//! - **Time Tracking**: Workdays and pause records for activity monitoring
//! - **Task Management**: Tasks, templates, and organizational features
//! - **Productivity Analytics**: Data aggregation and reporting support
//!
//! ## Usage
//!
//! ```rust,no_run
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! use kasl::db::{db::Db, tasks::Tasks, workdays::Workdays};
//! use kasl::libs::task::Task;
//!
//! let db = Db::new()?;
//! let mut tasks = Tasks::new()?;
//! let task = Task::new("Review code", "Check PR #123", Some(75));
//! tasks.insert(&task)?;
//! # Ok(())
//! # }
//! ```
//!
//! ```rust,no_run
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! use kasl::db::{tags::{Tags, Tag}, templates::{Templates, TaskTemplate}};
//!
//! // Create and manage tags
//! let mut tags = Tags::new()?;
//! let tag_id = tags.create(&Tag::new("urgent".to_string(), Some("red".to_string())))?;
//!
//! // Work with task templates
//! let mut templates = Templates::new()?;
//! let template = TaskTemplate::new(
//! "daily-standup".to_string(),
//! "Attend daily standup meeting".to_string(),
//! "Team sync and planning".to_string(),
//! 100
//! );
//! templates.create(&template)?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Performance Considerations
//!
//! ### Indexing Strategy
//! - **Temporal Queries**: Optimized indexes on timestamp columns
//! - **Relationship Lookups**: Efficient foreign key index coverage
//! - **Search Operations**: Selective indexes for common query patterns
//!
//! ### Connection Management
//! - **Connection Reuse**: Long-lived connections for better performance
//! - **Transaction Batching**: Grouped operations for improved throughput
//! - **Statement Preparation**: Cached prepared statements for repeated queries
//!
//! ### Data Volume Handling
//! - **Pagination Support**: Efficient handling of large result sets
//! - **Selective Loading**: Fetch only required fields for large tables
//! - **Archive Strategy**: Data retention policies for long-term usage
//!
//! ## Migration Best Practices
//!
//! ### Schema Evolution
//! ```text
//! // Adding a new column (backward compatible)
//! tx.execute("ALTER TABLE tasks ADD COLUMN priority INTEGER DEFAULT 1", [])?;
//!
//! // Creating new indexes for performance
//! tx.execute("CREATE INDEX idx_tasks_priority ON tasks(priority)", [])?;
//!
//! // Adding new tables with proper foreign keys
//! tx.execute("CREATE TABLE task_dependencies (
//! id INTEGER PRIMARY KEY,
//! task_id INTEGER NOT NULL,
//! depends_on INTEGER NOT NULL,
//! FOREIGN KEY (task_id) REFERENCES tasks(id) ON DELETE CASCADE,
//! FOREIGN KEY (depends_on) REFERENCES tasks(id) ON DELETE CASCADE
//! )", [])?;
//! ```
//!
//! ### Version Control Integration
//! - **Sequential Versioning**: Each migration increments the version number
//! - **Descriptive Names**: Clear migration names describing the change
//! - **Testing Requirements**: All migrations must be tested before deployment
//! - **Rollback Planning**: Consider rollback implications for schema changes
//!
//! ## Platform-Specific Considerations
//!
//! ### File System Integration
//! - **Windows**: Handles path length limitations and permission requirements
//! - **macOS**: Integrates with application sandbox restrictions
//! - **Linux**: Follows XDG base directory specifications
//!
//! ### Backup and Recovery
//! - **Export Functionality**: Complete data export in multiple formats
//! - **Import Validation**: Schema validation during data import
//! - **Corruption Recovery**: Database integrity checks and repair options
//!
//! ## Development and Debugging
//!
//! ### Debug Features
//! - **Migration Inspection**: View current schema version and history
//! - **Query Logging**: Optional SQL query logging for performance analysis
//! - **Connection Monitoring**: Track active connections and lock contention
//!
//! ### Testing Support
//! - **In-Memory Databases**: Fast test execution with temporary databases
//! - **Fixture Management**: Consistent test data setup and teardown
//! - **Migration Testing**: Automated testing of schema changes
/// Core database connection and initialization module.
///
/// Provides the fundamental `Db` struct that manages SQLite connections,
/// applies migrations, and ensures proper database configuration.
// kasl::db::db::Db is the established public path
/// Database schema migration system.
///
/// Handles versioned schema changes, tracks migration history, and provides
/// development-time migration management commands.
/// Local inbox of assigned open Jira issues.
///
/// Persists issues discovered by the background poller for toast notifications
/// and CLI selection / import into tasks.
/// Catalog of Jira status id → name pairs synced from issues.
/// Break and pause tracking operations.
///
/// Manages records of user inactivity periods, break times, and interruptions
/// during work sessions for productivity analysis.
/// Task categorization and organization system.
///
/// Provides tag-based organization for tasks, including many-to-many
/// relationships and color-coded categorization.
/// Core task management operations.
///
/// Handles CRUD operations for user tasks, including creation, updates,
/// completion tracking, and various filtering and search capabilities.
/// Reusable task template system.
///
/// Manages pre-defined task templates for common activities, enabling
/// quick task creation from standardized patterns.
/// Daily work session tracking.
///
/// Records work session start/end times, manages workday lifecycle, and
/// provides the foundation for time tracking and productivity reporting.