From 7b15606da5ebd01d8c8c1181955289b5bb739c8d Mon Sep 17 00:00:00 2001 From: Mahmoud-Emad Date: Wed, 28 May 2025 09:24:56 +0300 Subject: [PATCH] refactor: Remove unnecessary debug print statements - Removed several `println!` statements from the `governance` controller and `proposals` database module to improve code cleanliness and reduce unnecessary console output. - Updated the `all_activities.html` template to use the `created_at` field instead of `timestamp` for activity dates. - Updated the `index.html` template to use the `created_at` field instead of `timestamp` for activity timestamps. - Added `#[allow(unused_assignments)]` attribute to the `create_activity` function in `proposals.rs` to suppress a potentially unnecessary warning. --- actix_mvc_app/src/controllers/governance.rs | 14 ++++---------- actix_mvc_app/src/db/proposals.rs | 1 + .../src/views/governance/all_activities.html | 2 +- actix_mvc_app/src/views/governance/index.html | 2 +- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/actix_mvc_app/src/controllers/governance.rs b/actix_mvc_app/src/controllers/governance.rs index a8ca20b..21dbcc8 100644 --- a/actix_mvc_app/src/controllers/governance.rs +++ b/actix_mvc_app/src/controllers/governance.rs @@ -83,7 +83,6 @@ impl GovernanceController { /// Handles the governance dashboard page route pub async fn index(tmpl: web::Data, session: Session) -> Result { - println!("=============================================="); let mut ctx = tera::Context::new(); ctx.insert("active_page", "governance"); ctx.insert("active_tab", "dashboard"); @@ -100,14 +99,13 @@ impl GovernanceController { let user = Self::get_user_from_session(&session).unwrap(); ctx.insert("user", &user); - println!("=============================================="); // Get proposals from the database let proposals = match crate::db::proposals::get_proposals() { Ok(props) => { - println!( - "📋 Proposals list page: Successfully loaded {} proposals from database", - props.len() - ); + // println!( + // "📋 Proposals list page: Successfully loaded {} proposals from database", + // props.len() + // ); for (i, proposal) in props.iter().enumerate() { println!( " Proposal {}: ID={}, title={:?}, status={:?}", @@ -125,7 +123,6 @@ impl GovernanceController { vec![] } }; - println!("=============================================="); // Make a copy of proposals for statistics let proposals_for_stats = proposals.clone(); @@ -192,7 +189,6 @@ impl GovernanceController { ctx.insert("user", &user); } - println!("============== Loading proposals ================="); // Get proposals from the database let mut proposals = match get_proposals() { Ok(props) => props, @@ -202,8 +198,6 @@ impl GovernanceController { } }; - println!("proposals: {:?}", proposals); - // Filter proposals by status if provided if let Some(status_filter) = &query.status { if !status_filter.is_empty() { diff --git a/actix_mvc_app/src/db/proposals.rs b/actix_mvc_app/src/db/proposals.rs index e354c90..2f1f51b 100644 --- a/actix_mvc_app/src/db/proposals.rs +++ b/actix_mvc_app/src/db/proposals.rs @@ -189,6 +189,7 @@ pub fn submit_vote_on_proposal( Ok(updated_proposal) } +#[allow(unused_assignments)] /// Creates a new governance activity and saves it to the database using OurDB pub fn create_activity( proposal_id: u32, diff --git a/actix_mvc_app/src/views/governance/all_activities.html b/actix_mvc_app/src/views/governance/all_activities.html index ed5e048..f36ce82 100644 --- a/actix_mvc_app/src/views/governance/all_activities.html +++ b/actix_mvc_app/src/views/governance/all_activities.html @@ -54,7 +54,7 @@ - {{ activity.timestamp | date(format="%Y-%m-%d %H:%M") }} + {{ activity.created_at | date(format="%Y-%m-%d %H:%M") }} diff --git a/actix_mvc_app/src/views/governance/index.html b/actix_mvc_app/src/views/governance/index.html index f76db67..6d329a9 100644 --- a/actix_mvc_app/src/views/governance/index.html +++ b/actix_mvc_app/src/views/governance/index.html @@ -130,7 +130,7 @@
{{ activity.user }} - {{ activity.timestamp | date(format="%H:%M") }} + {{ activity.created_at | date(format="%H:%M") }}

{{ activity.action }} on {{