From 8af64cbf3586fbada051ecf4a48a28c9e632c806 Mon Sep 17 00:00:00 2001 From: Lucas Vas Date: Tue, 13 Jan 2026 16:13:46 -0500 Subject: [PATCH] feat: create static global constants for table names --- src/pages/api/comparisons.rs | 8 +++++--- src/pages/api/scholarships.rs | 14 ++++++++------ src/pages/provider_contact.rs | 7 +++++-- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/pages/api/comparisons.rs b/src/pages/api/comparisons.rs index 77fd3e9..b60acef 100644 --- a/src/pages/api/comparisons.rs +++ b/src/pages/api/comparisons.rs @@ -15,6 +15,8 @@ use crate::common::{ use leptos::prelude::ServerFnError; use leptos::server; +static COMPARISONS_TABLE: &str = "leptos-comparison-test"; + /// Helper function to create all sports comparisons. Only used to create initial /// comparison data, and should be removed upon completion of a comparison editor page. #[allow(unused)] @@ -386,7 +388,7 @@ pub async fn create_test_comparisons() -> Result<(), ServerFnError> { for comparison in comp_list { if let Err(err) = client .put_item() - .table_name("leptos-comparison-test") + .table_name(COMPARISONS_TABLE) .set_item(Some(serde_dynamo::to_item(&comparison)?)) .send() .await @@ -409,7 +411,7 @@ pub async fn get_comparison_info() -> Result, ServerFnError> // id and display text, but we'll return the whole thing. match client .scan() - .table_name("leptos-comparison-test") + .table_name(COMPARISONS_TABLE) .send() .await { @@ -435,7 +437,7 @@ pub async fn get_comparisons_categorized() -> Result Result { let client = create_dynamo_client().await; @@ -26,7 +28,7 @@ pub async fn get_scholarship_info(id: String) -> Result Result<(), ServerF match client .put_item() - .table_name("leptos-scholarship-test") + .table_name(SCHOLARSHIPS_TABLE) .set_item(Some(serde_dynamo::to_item(&info)?)) .send() .await @@ -77,7 +79,7 @@ pub async fn get_all_scholarship_info() -> Result, ServerFnE log!("Getting all scholarship info"); match client .scan() - .table_name("leptos-scholarship-test") + .table_name(SCHOLARSHIPS_TABLE) .send() .await { @@ -104,7 +106,7 @@ pub async fn get_provider_scholarships(provider_id: String) -> Result Result, ServerFnError> { use aws_sdk_dynamodb::types::AttributeValue; @@ -21,7 +24,7 @@ async fn get_provider_contact(id: String) -> Result, match client .get_item() - .table_name("leptos-provider-contacts") + .table_name(PROVIDER_CONTACT_TABLE) .key("subject", AttributeValue::S(id)) .send() .await @@ -58,7 +61,7 @@ async fn put_provider_contact(id: String, contact_info: HashMap