cognos: format
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ie85796e5a4eb173faacdb355bdd58ffd6a6a6964
This commit is contained in:
parent
d652faacc2
commit
58a3d68d22
2 changed files with 34 additions and 18 deletions
|
|
@ -11,16 +11,28 @@ pub use aterm::{
|
||||||
parse_drv_file,
|
parse_drv_file,
|
||||||
};
|
};
|
||||||
pub use internal_json::{Actions, Activities, Id, Verbosity};
|
pub use internal_json::{Actions, Activities, Id, Verbosity};
|
||||||
pub use state::{BuildInfo, BuildStatus, Dependencies, Derivation, Host, OutputName, State, ProgressState};
|
pub use state::{
|
||||||
|
BuildInfo,
|
||||||
|
BuildStatus,
|
||||||
|
Dependencies,
|
||||||
|
Derivation,
|
||||||
|
Host,
|
||||||
|
OutputName,
|
||||||
|
ProgressState,
|
||||||
|
State,
|
||||||
|
};
|
||||||
|
|
||||||
/// Process a list of actions and return the resulting state
|
/// Process a list of actions and return the resulting state
|
||||||
#[must_use] pub fn process_actions(actions: Vec<Actions>) -> State {
|
#[must_use]
|
||||||
|
pub fn process_actions(actions: Vec<Actions>) -> State {
|
||||||
let mut state = State {
|
let mut state = State {
|
||||||
progress: ProgressState::JustStarted,
|
progress: ProgressState::JustStarted,
|
||||||
derivations: HashMap::new(),
|
derivations: HashMap::new(),
|
||||||
builds: HashMap::new(),
|
builds: HashMap::new(),
|
||||||
dependencies: Dependencies { deps: HashMap::new() },
|
dependencies: Dependencies {
|
||||||
store_paths: HashMap::new(),
|
deps: HashMap::new(),
|
||||||
|
},
|
||||||
|
store_paths: HashMap::new(),
|
||||||
dependency_states: HashMap::new(),
|
dependency_states: HashMap::new(),
|
||||||
};
|
};
|
||||||
for action in actions {
|
for action in actions {
|
||||||
|
|
|
||||||
|
|
@ -97,18 +97,22 @@ pub struct Dependencies {
|
||||||
|
|
||||||
// #[derive(Default)]
|
// #[derive(Default)]
|
||||||
pub struct State {
|
pub struct State {
|
||||||
pub progress: ProgressState,
|
pub progress: ProgressState,
|
||||||
pub derivations: HashMap<Id, Derivation>,
|
pub derivations: HashMap<Id, Derivation>,
|
||||||
pub builds: HashMap<Id, BuildInfo>,
|
pub builds: HashMap<Id, BuildInfo>,
|
||||||
pub dependencies: Dependencies,
|
pub dependencies: Dependencies,
|
||||||
pub store_paths: HashMap<Id, StorePath>,
|
pub store_paths: HashMap<Id, StorePath>,
|
||||||
pub dependency_states: HashMap<Id, DependencyState>,
|
pub dependency_states: HashMap<Id, DependencyState>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl State {
|
impl State {
|
||||||
pub fn imbibe(&mut self, action: Actions) {
|
pub fn imbibe(&mut self, action: Actions) {
|
||||||
match action {
|
match action {
|
||||||
Actions::Start { id, activity: _activity, .. } => {
|
Actions::Start {
|
||||||
|
id,
|
||||||
|
activity: _activity,
|
||||||
|
..
|
||||||
|
} => {
|
||||||
let derivation = Derivation {
|
let derivation = Derivation {
|
||||||
store_path: PathBuf::from("/nix/store/placeholder"),
|
store_path: PathBuf::from("/nix/store/placeholder"),
|
||||||
};
|
};
|
||||||
|
|
@ -118,11 +122,11 @@ impl State {
|
||||||
let _path = &self.derivations.get(&id).unwrap().store_path;
|
let _path = &self.derivations.get(&id).unwrap().store_path;
|
||||||
|
|
||||||
let build_info = BuildInfo {
|
let build_info = BuildInfo {
|
||||||
start: 0.0, // Placeholder, would need actual time
|
start: 0.0, // Placeholder, would need actual time
|
||||||
host: Host::Localhost, // Placeholder
|
host: Host::Localhost, // Placeholder
|
||||||
estimate: None,
|
estimate: None,
|
||||||
activity_id: id,
|
activity_id: id,
|
||||||
state: BuildStatus::Running,
|
state: BuildStatus::Running,
|
||||||
};
|
};
|
||||||
self.builds.insert(id, build_info.clone());
|
self.builds.insert(id, build_info.clone());
|
||||||
self.dependencies.deps.insert(id, build_info);
|
self.dependencies.deps.insert(id, build_info);
|
||||||
|
|
@ -152,4 +156,4 @@ impl State {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue