use super::super::{BoardRow, Facts};
use crate::app::Snapshot;
use crate::board::Column;
use crate::git_tree::GitTree;
use crate::projects::join::JoinState;
use std::path::{Path, PathBuf};
use std::time::Duration;
pub(super) const WS: &str = "/names/otter";
pub(super) const PROJECT: &str = "/dev/yog";
pub(super) const NOW: i64 = 1_000_000;
pub(super) fn facts(cap: usize, count: usize, lease: Option<Duration>) -> Facts {
Facts {
workspace: PathBuf::from(WS),
project: PathBuf::from(PROJECT),
cap,
count,
tick: Duration::from_secs(15),
lease,
since_act: None,
ceiling: None,
}
}
pub(super) fn row(id: &str, column: Column, drones: Vec<&str>) -> BoardRow {
let mine = column == Column::Claimed;
BoardRow {
project: crate::naming::leaf(Path::new(PROJECT)),
id: id.to_owned(),
title: format!("title of {id}"),
priority: 0,
column,
state: if mine {
JoinState::Bound
} else {
JoinState::ReadyStartable
},
workspace: mine.then(|| crate::naming::leaf(Path::new(WS))),
claimant: mine.then(|| "otter".to_owned()),
parent: None,
gates: vec![],
drones: drones
.into_iter()
.map(|root| crate::board::Drone {
root_id: root.to_owned(),
name: root.to_owned(),
})
.collect(),
spend: None,
rollup: None,
}
}
pub(super) fn snap(agents: Vec<crate::git_tree::Agent>) -> Snapshot {
let mut snap = Snapshot::empty(0);
snap.projects = vec![PathBuf::from(PROJECT)];
snap.trees.insert(
PathBuf::from(WS),
GitTree {
commits: vec![],
agents,
},
);
snap
}