Skip to content
This repository was archived by the owner on Jun 11, 2026. It is now read-only.

Commit 69a8cea

Browse files
committed
add all time date range
1 parent 199f846 commit 69a8cea

4 files changed

Lines changed: 25 additions & 11 deletions

File tree

src/cli.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub struct Cli {
4242
pub enum Commands {
4343
/// Interactive usage dashboard (default when no subcommand given)
4444
Report {
45-
/// Starting period: today, week, 30days, month
45+
/// Starting period: today, week, 30days, month, all
4646
#[arg(short, long, default_value = "week")]
4747
period: Period,
4848

@@ -137,6 +137,7 @@ pub enum Period {
137137
#[value(name = "30days")]
138138
ThirtyDays,
139139
Month,
140+
All,
140141
}
141142

142143
#[derive(Debug, Clone, Copy, ValueEnum)]

src/export.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,15 @@ pub async fn run_export(format: ExportFormat, output: Option<String>, provider:
140140
let periods = vec![
141141
PeriodExport {
142142
label: "Today".to_string(),
143-
projects: parse_all_sessions(Some(&get_date_range("today")), pf, &empty_prestats)?,
143+
projects: parse_all_sessions(get_date_range("today").as_ref(), pf, &empty_prestats)?,
144144
},
145145
PeriodExport {
146146
label: "7 Days".to_string(),
147-
projects: parse_all_sessions(Some(&get_date_range("week")), pf, &empty_prestats)?,
147+
projects: parse_all_sessions(get_date_range("week").as_ref(), pf, &empty_prestats)?,
148148
},
149149
PeriodExport {
150150
label: "30 Days".to_string(),
151-
projects: parse_all_sessions(Some(&get_date_range("30days")), pf, &empty_prestats)?,
151+
projects: parse_all_sessions(get_date_range("30days").as_ref(), pf, &empty_prestats)?,
152152
},
153153
];
154154

src/tui/mod.rs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const PERIODS: &[(&str, &str)] = &[
5151
("week", "7 Days"),
5252
("30days", "30 Days"),
5353
("month", "This Month"),
54+
("all", "All Time"),
5455
];
5556

5657
fn period_to_index(p: &str) -> usize {
@@ -59,6 +60,7 @@ fn period_to_index(p: &str) -> usize {
5960
"week" => 1,
6061
"30days" => 2,
6162
"month" => 3,
63+
"all" => 4,
6264
_ => 1,
6365
}
6466
}
@@ -69,6 +71,7 @@ fn period_str(p: Period) -> &'static str {
6971
Period::Week => "week",
7072
Period::ThirtyDays => "30days",
7173
Period::Month => "month",
74+
Period::All => "all",
7275
}
7376
}
7477

@@ -153,7 +156,10 @@ where
153156
Ok(())
154157
}
155158

156-
pub fn get_date_range(period: &str) -> DateRange {
159+
pub fn get_date_range(period: &str) -> Option<DateRange> {
160+
if period == "all" {
161+
return None;
162+
}
157163
let now = Local::now();
158164
let today_start = now
159165
.date_naive()
@@ -196,7 +202,7 @@ pub fn get_date_range(period: &str) -> DateRange {
196202
.unwrap(),
197203
};
198204

199-
DateRange { start, end }
205+
Some(DateRange { start, end })
200206
}
201207

202208
pub struct App {
@@ -323,7 +329,7 @@ impl App {
323329
let tx = tx.clone();
324330
std::thread::spawn(move || {
325331
let projects = parse_all_sessions(
326-
Some(&date_range),
332+
date_range.as_ref(),
327333
filter.as_deref(),
328334
&HashMap::new(),
329335
)
@@ -481,7 +487,7 @@ pub fn run(period: Period, provider: &str, refresh: Option<u64>) -> Result<()> {
481487
let tx2 = tx.clone();
482488
std::thread::spawn(move || {
483489
let projects = parse_all_sessions(
484-
Some(&date_range),
490+
date_range.as_ref(),
485491
filter.as_deref(),
486492
&HashMap::new(),
487493
)
@@ -634,6 +640,12 @@ pub fn run(period: Period, provider: &str, refresh: Option<u64>) -> Result<()> {
634640
app.switch_to(&tx);
635641
}
636642
}
643+
KeyCode::Char('5') => {
644+
if app.period_idx != 4 {
645+
app.period_idx = 4;
646+
app.switch_to(&tx);
647+
}
648+
}
637649
KeyCode::Left | KeyCode::Char('<') => {
638650
if app.last_switch.elapsed() > Duration::from_millis(120) {
639651
app.period_idx =
@@ -789,7 +801,7 @@ fn run_render_once(period: Period, provider: &str) -> Result<()> {
789801

790802
let date_range = get_date_range(period_str(period));
791803
let filter = if provider == "all" { None } else { Some(provider) };
792-
app.projects = crate::parser::parse_all_sessions(Some(&date_range), filter, pre_stats)
804+
app.projects = crate::parser::parse_all_sessions(date_range.as_ref(), filter, pre_stats)
793805
.unwrap_or_default();
794806
app.loading = false;
795807

@@ -904,7 +916,7 @@ pub fn run_static_sync(period: Period, provider: &str) -> Result<()> {
904916
// orthogonal to this cleanup.
905917
let date_range = get_date_range(period_str(period));
906918
let filter = if provider == "all" { None } else { Some(provider) };
907-
let agg = parse_all_sessions_static(Some(&date_range), filter).unwrap_or_default();
919+
let agg = parse_all_sessions_static(date_range.as_ref(), filter).unwrap_or_default();
908920

909921
let mut buf: Vec<u8> = Vec::with_capacity(1024);
910922
render_static_aggregate_into(&mut buf, period, &agg);
@@ -959,7 +971,7 @@ fn run_static(period: Period, provider: &str) -> Result<()> {
959971
} else {
960972
Some(provider)
961973
};
962-
let projects = parse_all_sessions(Some(&date_range), filter, &HashMap::new())
974+
let projects = parse_all_sessions(date_range.as_ref(), filter, &HashMap::new())
963975
.unwrap_or_default();
964976
render_static(period, &projects);
965977
Ok(())

src/tui/widgets/chrome.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ pub fn render_status_bar(buf: &mut Buffer, area: Rect) {
5959
kb("2"), lbl(" week "),
6060
kb("3"), lbl(" 30 days "),
6161
kb("4"), lbl(" month "),
62+
kb("5"), lbl(" all "),
6263
kb("p"), lbl(" provider"),
6364
]);
6465
let block = Block::default()

0 commit comments

Comments
 (0)