From 899451f61a30334b2bceb56cec8522a3ff84ffa4 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 22 Apr 2024 22:03:21 +0200 Subject: [PATCH] slight renaming and adding zome functions to get all original developer collectives and original tools --- .../library/src/all_developer_collectives.rs | 27 ++++++++++++++++- .../zomes/coordinator/library/src/tool.rs | 30 ++++++++++++++++++- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/dnas/tools/zomes/coordinator/library/src/all_developer_collectives.rs b/dnas/tools/zomes/coordinator/library/src/all_developer_collectives.rs index 5d8d663..6c476de 100644 --- a/dnas/tools/zomes/coordinator/library/src/all_developer_collectives.rs +++ b/dnas/tools/zomes/coordinator/library/src/all_developer_collectives.rs @@ -1,10 +1,35 @@ use hdk::prelude::*; use library_integrity::*; #[hdk_extern] -pub fn get_all_developer_collectives(_: ()) -> ExternResult> { +pub fn get_all_developer_collective_links(_: ()) -> ExternResult> { let path = Path::from("all_developer_collectives"); get_links( GetLinksInputBuilder::try_new(path.path_entry_hash()?, LinkTypes::AllDeveloperCollectives)? .build(), ) } + +#[hdk_extern] +pub fn get_all_original_developer_collectives(_: ()) -> ExternResult> { + let path = Path::from("all_developer_collectives"); + let links = get_links( + GetLinksInputBuilder::try_new(path.path_entry_hash()?, LinkTypes::AllDeveloperCollectives)? + .build(), + )?; + let get_input: Vec = links + .into_iter() + .map(|link| { + Ok(GetInput::new( + link.target + .into_action_hash() + .ok_or(wasm_error!(WasmErrorInner::Guest( + "No action hash associated with link".to_string() + )))? + .into(), + GetOptions::default(), + )) + }) + .collect::>>()?; + let records = HDK.with(|hdk| hdk.borrow().get(get_input))?; + Ok(records.into_iter().flatten().collect()) +} diff --git a/dnas/tools/zomes/coordinator/library/src/tool.rs b/dnas/tools/zomes/coordinator/library/src/tool.rs index 2601149..06fec66 100644 --- a/dnas/tools/zomes/coordinator/library/src/tool.rs +++ b/dnas/tools/zomes/coordinator/library/src/tool.rs @@ -203,7 +203,7 @@ pub fn get_oldest_delete_for_tool( Ok(deletes.first().cloned()) } #[hdk_extern] -pub fn get_tools_for_developer_collective( +pub fn get_tool_links_for_developer_collective( developer_collective_hash: ActionHash, ) -> ExternResult> { get_links( @@ -215,6 +215,34 @@ pub fn get_tools_for_developer_collective( ) } #[hdk_extern] +pub fn get_original_tools_for_developer_collective( + developer_collective_hash: ActionHash, +) -> ExternResult> { + let links = get_links( + GetLinksInputBuilder::try_new( + developer_collective_hash, + LinkTypes::DeveloperCollectiveToTools, + )? + .build(), + )?; + let get_input: Vec = links + .into_iter() + .map(|link| { + Ok(GetInput::new( + link.target + .into_action_hash() + .ok_or(wasm_error!(WasmErrorInner::Guest( + "No action hash associated with link".to_string() + )))? + .into(), + GetOptions::default(), + )) + }) + .collect::>>()?; + let records = HDK.with(|hdk| hdk.borrow().get(get_input))?; + Ok(records.into_iter().flatten().collect()) +} +#[hdk_extern] pub fn get_deleted_tools_for_developer_collective( developer_collective_hash: ActionHash, ) -> ExternResult)>> {