list entries by most recent last in --interactive
This commit is contained in:
parent
a9bfc1a95a
commit
f968e6605c
|
@ -120,7 +120,7 @@ where
|
||||||
table.feed(vec!["#", "Note", "Total time", "Last started"]);
|
table.feed(vec!["#", "Note", "Total time", "Last started"]);
|
||||||
table.separator(' ');
|
table.separator(' ');
|
||||||
|
|
||||||
for (i, entry) in uniques.iter().take(facts.config.interactive_entries).enumerate() {
|
for (i, entry) in uniques.iter().take(facts.config.interactive_entries).enumerate().rev() {
|
||||||
let i = i + 1;
|
let i = i + 1;
|
||||||
let ago = formatter.convert_chrono(entry.last_start, facts.now);
|
let ago = formatter.convert_chrono(entry.last_start, facts.now);
|
||||||
|
|
||||||
|
@ -216,15 +216,15 @@ mod tests {
|
||||||
streams.db.entry_insert(one_hour_ago, Some(facts.now), Some("second task".into()), "default").unwrap();
|
streams.db.entry_insert(one_hour_ago, Some(facts.now), Some("second task".into()), "default").unwrap();
|
||||||
|
|
||||||
// call the command interactively
|
// call the command interactively
|
||||||
note_from_last_entries(&mut streams, &facts, "default").unwrap();
|
assert_eq!(note_from_last_entries(&mut streams, &facts, "default").unwrap().unwrap(), "second task");
|
||||||
|
|
||||||
// check the output
|
// check the output
|
||||||
assert_str_eq!(&String::from_utf8_lossy(&streams.out), "Latest entries of sheet 'default':
|
assert_str_eq!(&String::from_utf8_lossy(&streams.out), "Latest entries of sheet 'default':
|
||||||
|
|
||||||
# Note Total time Last started
|
# Note Total time Last started
|
||||||
|
|
||||||
1 second task 1:00:00 1 hour ago
|
|
||||||
2 first task 1:00:00 2 hours ago
|
2 first task 1:00:00 2 hours ago
|
||||||
|
1 second task 1:00:00 1 hour ago
|
||||||
|
|
||||||
enter number or q to cancel
|
enter number or q to cancel
|
||||||
>> ");
|
>> ");
|
||||||
|
@ -251,17 +251,17 @@ enter number or q to cancel
|
||||||
streams.db.entry_insert(facts.now - Duration::minutes(4), Some(facts.now - Duration::minutes(3)), Some("task 6".into()), "default").unwrap();
|
streams.db.entry_insert(facts.now - Duration::minutes(4), Some(facts.now - Duration::minutes(3)), Some("task 6".into()), "default").unwrap();
|
||||||
|
|
||||||
// call the command interactively
|
// call the command interactively
|
||||||
note_from_last_entries(&mut streams, &facts, "default").unwrap();
|
assert_eq!(note_from_last_entries(&mut streams, &facts, "default").unwrap().unwrap(), "task 6");
|
||||||
|
|
||||||
// check the output
|
// check the output
|
||||||
assert_str_eq!(&String::from_utf8_lossy(&streams.out), "Latest entries of sheet 'default':
|
assert_str_eq!(&String::from_utf8_lossy(&streams.out), "Latest entries of sheet 'default':
|
||||||
|
|
||||||
# Note Total time Last started
|
# Note Total time Last started
|
||||||
|
|
||||||
1 task 6 0:01:00 4 minutes ago
|
|
||||||
2 task 5 0:01:00 5 minutes ago
|
|
||||||
3 task 4 0:01:00 6 minutes ago
|
|
||||||
4 task 3 0:01:00 7 minutes ago
|
4 task 3 0:01:00 7 minutes ago
|
||||||
|
3 task 4 0:01:00 6 minutes ago
|
||||||
|
2 task 5 0:01:00 5 minutes ago
|
||||||
|
1 task 6 0:01:00 4 minutes ago
|
||||||
|
|
||||||
enter number or q to cancel
|
enter number or q to cancel
|
||||||
>> ");
|
>> ");
|
||||||
|
|
Loading…
Reference in New Issue