Merge pull request #1392 from matthiasbeyer/libimagdiary/list-sorted
Fix: view entries sorted
This commit is contained in:
commit
633032586d
1 changed files with 10 additions and 6 deletions
|
@ -27,7 +27,6 @@ use error::Result;
|
||||||
use libimagstore::store::FileLockEntry;
|
use libimagstore::store::FileLockEntry;
|
||||||
use libimagentryview::viewer::Viewer;
|
use libimagentryview::viewer::Viewer;
|
||||||
use libimagentryview::builtin::plain::PlainViewer;
|
use libimagentryview::builtin::plain::PlainViewer;
|
||||||
use libimagerror::trace::trace_error;
|
|
||||||
|
|
||||||
/// This viewer does _not_ implement libimagentryview::viewer::Viewer because we need to be able to
|
/// This viewer does _not_ implement libimagentryview::viewer::Viewer because we need to be able to
|
||||||
/// call some diary-type specific functions on the entries passed to this.
|
/// call some diary-type specific functions on the entries passed to this.
|
||||||
|
@ -49,11 +48,16 @@ impl DiaryViewer {
|
||||||
/// View all entries from the iterator, or stop immediately if an error occurs, returning that
|
/// View all entries from the iterator, or stop immediately if an error occurs, returning that
|
||||||
/// error.
|
/// error.
|
||||||
pub fn view_entries<'a, I: Iterator<Item = FileLockEntry<'a>>>(&self, entries: I) -> Result<()> {
|
pub fn view_entries<'a, I: Iterator<Item = FileLockEntry<'a>>>(&self, entries: I) -> Result<()> {
|
||||||
for entry in entries {
|
let mut entries = entries
|
||||||
match entry.diary_id() {
|
.map(|e| e.diary_id().map(|id| (id, e)))
|
||||||
Ok(id) => println!("{} :\n", id),
|
.collect::<Result<Vec<_>>>()?;
|
||||||
Err(e) => trace_error(&e),
|
|
||||||
}
|
entries.sort_by_key(|&(ref id, _)| {
|
||||||
|
[id.year() as u32, id.month(), id.day(), id.hour(), id.minute(), id.second()]
|
||||||
|
});
|
||||||
|
|
||||||
|
for (id, entry) in entries.into_iter() {
|
||||||
|
println!("{} :\n", id);
|
||||||
let _ = self.0
|
let _ = self.0
|
||||||
.view_entry(&entry)
|
.view_entry(&entry)
|
||||||
.chain_err(|| DEK::ViewError)
|
.chain_err(|| DEK::ViewError)
|
||||||
|
|
Loading…
Reference in a new issue