-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ml data * ml data changes * memory id changes
- Loading branch information
1 parent
f869ac7
commit 0763b61
Showing
15 changed files
with
423 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/canister/individual_user_template/src/api/ml_ops/get_history.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use shared_utils::{ | ||
canister_specific::individual_user_template::types::ml_data::{ | ||
SuccessHistoryItem, WatchHistoryItem, | ||
}, | ||
common::utils::permissions::is_caller_controller_or_global_admin, | ||
}; | ||
|
||
use ic_cdk_macros::query; | ||
|
||
use crate::{ | ||
api::canister_management::update_last_access_time::update_last_canister_functionality_access_time, | ||
CANISTER_DATA, | ||
}; | ||
|
||
#[query(guard = "is_caller_controller_or_global_admin")] | ||
fn get_watch_history() -> Result<Vec<WatchHistoryItem>, String> { | ||
update_last_canister_functionality_access_time(); | ||
|
||
CANISTER_DATA.with(|canister_data| { | ||
let canister_data = canister_data.borrow(); | ||
Ok(canister_data | ||
.watch_history | ||
.iter() | ||
.map(|(k, _)| k.clone()) | ||
.collect()) | ||
}) | ||
} | ||
|
||
#[query(guard = "is_caller_controller_or_global_admin")] | ||
fn get_success_history() -> Result<Vec<SuccessHistoryItem>, String> { | ||
update_last_canister_functionality_access_time(); | ||
|
||
CANISTER_DATA.with(|canister_data| { | ||
let canister_data = canister_data.borrow(); | ||
Ok(canister_data | ||
.success_history | ||
.iter() | ||
.map(|(k, _)| k.clone()) | ||
.collect()) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub mod get_history; | ||
pub mod update_success_history; | ||
pub mod update_watch_history; |
25 changes: 25 additions & 0 deletions
25
src/canister/individual_user_template/src/api/ml_ops/update_success_history.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use shared_utils::{ | ||
canister_specific::individual_user_template::types::ml_data::SuccessHistoryItem, | ||
common::utils::permissions::is_caller_controller_or_global_admin, | ||
}; | ||
|
||
use ic_cdk_macros::update; | ||
|
||
use crate::{ | ||
api::canister_management::update_last_access_time::update_last_canister_functionality_access_time, | ||
CANISTER_DATA, | ||
}; | ||
|
||
#[update(guard = "is_caller_controller_or_global_admin")] | ||
fn update_success_history(success_history_item: SuccessHistoryItem) -> Result<String, String> { | ||
update_last_canister_functionality_access_time(); | ||
|
||
CANISTER_DATA.with(|canister_data| { | ||
let mut canister_data = canister_data.borrow_mut(); | ||
canister_data | ||
.success_history | ||
.insert(success_history_item, ()); | ||
}); | ||
|
||
Ok("Success".into()) | ||
} |
23 changes: 23 additions & 0 deletions
23
src/canister/individual_user_template/src/api/ml_ops/update_watch_history.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use shared_utils::{ | ||
canister_specific::individual_user_template::types::ml_data::WatchHistoryItem, | ||
common::utils::permissions::is_caller_controller_or_global_admin, | ||
}; | ||
|
||
use ic_cdk_macros::update; | ||
|
||
use crate::{ | ||
api::canister_management::update_last_access_time::update_last_canister_functionality_access_time, | ||
CANISTER_DATA, | ||
}; | ||
|
||
#[update(guard = "is_caller_controller_or_global_admin")] | ||
fn update_watch_history(watch_history_item: WatchHistoryItem) -> Result<String, String> { | ||
update_last_canister_functionality_access_time(); | ||
|
||
CANISTER_DATA.with(|canister_data| { | ||
let mut canister_data = canister_data.borrow_mut(); | ||
canister_data.watch_history.insert(watch_history_item, ()); | ||
}); | ||
|
||
Ok("Success".into()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.