list entries by most recent last in --interactive

This commit is contained in:
Abraham Toriz 2022-08-04 18:51:17 +08:00
parent a9bfc1a95a
commit f968e6605c
No known key found for this signature in database
GPG Key ID: D5B4A746DB5DD42A
1 changed files with 7 additions and 7 deletions

View File

@ -120,7 +120,7 @@ where
table.feed(vec!["#", "Note", "Total time", "Last started"]);
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 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();
// 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
assert_str_eq!(&String::from_utf8_lossy(&streams.out), "Latest entries of sheet 'default':
# Note Total time Last started
1 second task 1:00:00 1 hour 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
>> ");
@ -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();
// 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
assert_str_eq!(&String::from_utf8_lossy(&streams.out), "Latest entries of sheet 'default':
# 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
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
>> ");