Page MenuHomePhabricator

D10428.diff
No OneTemporary

D10428.diff

diff --git a/services/backup/src/database/backup_item.rs b/services/backup/src/database/backup_item.rs
--- a/services/backup/src/database/backup_item.rs
+++ b/services/backup/src/database/backup_item.rs
@@ -50,6 +50,22 @@
);
}
}
+
+ pub fn item_key(
+ user_id: &str,
+ backup_id: &str,
+ ) -> HashMap<String, AttributeValue> {
+ HashMap::from([
+ (
+ backup_table::attr::USER_ID.to_string(),
+ AttributeValue::S(user_id.to_string()),
+ ),
+ (
+ backup_table::attr::BACKUP_ID.to_string(),
+ AttributeValue::S(backup_id.to_string()),
+ ),
+ ])
+ }
}
impl From<BackupItem> for HashMap<String, AttributeValue> {
diff --git a/services/backup/src/database/mod.rs b/services/backup/src/database/mod.rs
--- a/services/backup/src/database/mod.rs
+++ b/services/backup/src/database/mod.rs
@@ -8,7 +8,6 @@
types::{AttributeValue, ReturnValue},
};
use comm_lib::database::Error;
-use std::collections::HashMap;
use tracing::{error, trace, warn};
#[derive(Clone)]
@@ -22,8 +21,10 @@
client: aws_sdk_dynamodb::Client::new(aws_config),
}
}
+}
- // backup item
+/// Backup functions
+impl DatabaseClient {
pub async fn put_backup_item(
&self,
backup_item: BackupItem,
@@ -50,7 +51,7 @@
user_id: &str,
backup_id: &str,
) -> Result<Option<BackupItem>, Error> {
- let item_key = Self::get_item_key(user_id, backup_id);
+ let item_key = BackupItem::item_key(user_id, backup_id);
let output = self
.client
@@ -112,7 +113,7 @@
user_id: &str,
backup_id: &str,
) -> Result<Option<BackupItem>, Error> {
- let item_key = Self::get_item_key(user_id, backup_id);
+ let item_key = BackupItem::item_key(user_id, backup_id);
let response = self
.client
@@ -201,20 +202,4 @@
Ok(removed_backups)
}
-
- fn get_item_key(
- user_id: &str,
- backup_id: &str,
- ) -> HashMap<String, AttributeValue> {
- HashMap::from([
- (
- backup_table::attr::USER_ID.to_string(),
- AttributeValue::S(user_id.to_string()),
- ),
- (
- backup_table::attr::BACKUP_ID.to_string(),
- AttributeValue::S(backup_id.to_string()),
- ),
- ])
- }
}

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 21, 9:20 AM (17 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2687247
Default Alt Text
D10428.diff (2 KB)

Event Timeline