forked from janek/mostr
refactor: reformat
This commit is contained in:
parent
1ea34898d1
commit
9a2f3f8794
|
@ -1 +1,4 @@
|
|||
/target
|
||||
|
||||
*.html
|
||||
/src/bin
|
||||
|
|
|
@ -215,7 +215,8 @@ async fn repl() {
|
|||
tasks.update_state("", |t| if t.pure_state() == State::Active { Some(State::Open) } else { None });
|
||||
|
||||
println!();
|
||||
println!("Submitting created events");
|
||||
println!("Submitting events");
|
||||
// TODO send via message passing
|
||||
let _ = CLIENT
|
||||
.batch_event(
|
||||
tasks
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::fmt;
|
||||
use nostr_sdk::{Event, EventId, Kind, Tag, Timestamp};
|
||||
use crate::make_event;
|
||||
use nostr_sdk::{Event, EventId, Kind, Tag, Timestamp};
|
||||
use std::fmt;
|
||||
|
||||
pub(crate) struct Task {
|
||||
pub(crate) event: Event,
|
||||
|
|
23
src/tasks.rs
23
src/tasks.rs
|
@ -1,8 +1,10 @@
|
|||
use crate::{make_event, make_task};
|
||||
use crate::task::{Task, State};
|
||||
use nostr_sdk::{Event, EventId, Tag};
|
||||
use std::collections::HashMap;
|
||||
|
||||
use nostr_sdk::{Event, EventId, Tag};
|
||||
|
||||
use crate::make_task;
|
||||
use crate::task::{State, Task};
|
||||
|
||||
type TaskMap = HashMap<EventId, Task>;
|
||||
pub(crate) struct Tasks {
|
||||
/// The Tasks
|
||||
|
@ -38,7 +40,11 @@ impl Tasks {
|
|||
/// Total time this task and its subtasks have been active
|
||||
fn total_time_tracked(&self, task: &EventId) -> u64 {
|
||||
self.tasks.get(task).map_or(0, |t| {
|
||||
t.time_tracked() + t.children.iter().map(|e| self.total_time_tracked(e)).sum::<u64>()
|
||||
t.time_tracked()
|
||||
+ t.children
|
||||
.iter()
|
||||
.map(|e| self.total_time_tracked(e))
|
||||
.sum::<u64>()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -54,10 +60,11 @@ impl Tasks {
|
|||
self.position.map_or_else(
|
||||
|| self.tasks.values().collect(),
|
||||
|p| {
|
||||
self.tasks.get(&p).map_or(Vec::new(), |t| {
|
||||
self.collect_tasks(&t.children)
|
||||
})
|
||||
})
|
||||
self.tasks
|
||||
.get(&p)
|
||||
.map_or(Vec::new(), |t| self.collect_tasks(&t.children))
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn print_current_tasks(&self) {
|
||||
|
|
Loading…
Reference in New Issue