Month -> 31 trailing days

This commit is contained in:
Ian Keane 2025-12-01 15:13:40 -05:00
parent e62832fde6
commit 360af2f0cb
2 changed files with 45 additions and 33 deletions

View file

@ -28,7 +28,7 @@ pub enum Screen {
pub enum LogViewPeriod {
Day,
Week,
Month,
Month, // Represents the last 31 days
}
pub enum LogViewDayOrder {
@ -1587,17 +1587,29 @@ impl App {
}
fn load_log_content(&mut self) -> anyhow::Result<()> {
let flag = match self.log_view_period {
LogViewPeriod::Day => "--day",
LogViewPeriod::Week => "--week",
LogViewPeriod::Month => "--month",
let mut command = Command::new("watson");
command.arg("log").arg("--json");
// Handle different period options
match self.log_view_period {
LogViewPeriod::Day => {
command.arg("--day");
},
LogViewPeriod::Week => {
command.arg("--week");
},
LogViewPeriod::Month => {
// Use --from with date 31 days ago for month view
let thirty_one_days_ago = chrono::Local::now()
.checked_sub_signed(chrono::Duration::days(31))
.expect("Failed to calculate date from 31 days ago");
command.arg("--from");
command.arg(thirty_one_days_ago.format("%Y-%m-%d").to_string());
},
};
let output = Command::new("watson")
.arg("log")
.arg(flag)
.arg("--json")
.output()?;
let output = command.output()?;
if output.status.success() {
let json_str = String::from_utf8_lossy(&output.stdout);

View file

@ -679,7 +679,7 @@ fn render_log_view(frame: &mut Frame, app: &App) {
let period_str = match app.log_view_period {
LogViewPeriod::Day => "Day",
LogViewPeriod::Week => "Week",
LogViewPeriod::Month => "Month",
LogViewPeriod::Month => "31 Days",
};
let grouping_str = match app.log_view_grouping {
@ -928,7 +928,7 @@ fn render_log_view_help(frame: &mut Frame, app: &App) {
"Time Periods:",
"- d: Switch to Day view (current day)",
"- w: Switch to Week view (current week)",
"- m: Switch to Month view (current month)",
"- m: Switch to Month view (last 31 days)",
"",
"Grouping:",
"- g: Toggle between grouping by Date or by Project",