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.
This commit is contained in:
Mahmoud-Emad 2025-05-28 09:24:56 +03:00
parent 11d7ae37b6
commit 7b15606da5
4 changed files with 7 additions and 12 deletions

View File

@ -83,7 +83,6 @@ impl GovernanceController {
/// Handles the governance dashboard page route /// Handles the governance dashboard page route
pub async fn index(tmpl: web::Data<Tera>, session: Session) -> Result<impl Responder> { pub async fn index(tmpl: web::Data<Tera>, session: Session) -> Result<impl Responder> {
println!("==============================================");
let mut ctx = tera::Context::new(); let mut ctx = tera::Context::new();
ctx.insert("active_page", "governance"); ctx.insert("active_page", "governance");
ctx.insert("active_tab", "dashboard"); ctx.insert("active_tab", "dashboard");
@ -100,14 +99,13 @@ impl GovernanceController {
let user = Self::get_user_from_session(&session).unwrap(); let user = Self::get_user_from_session(&session).unwrap();
ctx.insert("user", &user); ctx.insert("user", &user);
println!("==============================================");
// Get proposals from the database // Get proposals from the database
let proposals = match crate::db::proposals::get_proposals() { let proposals = match crate::db::proposals::get_proposals() {
Ok(props) => { Ok(props) => {
println!( // println!(
"📋 Proposals list page: Successfully loaded {} proposals from database", // "📋 Proposals list page: Successfully loaded {} proposals from database",
props.len() // props.len()
); // );
for (i, proposal) in props.iter().enumerate() { for (i, proposal) in props.iter().enumerate() {
println!( println!(
" Proposal {}: ID={}, title={:?}, status={:?}", " Proposal {}: ID={}, title={:?}, status={:?}",
@ -125,7 +123,6 @@ impl GovernanceController {
vec![] vec![]
} }
}; };
println!("==============================================");
// Make a copy of proposals for statistics // Make a copy of proposals for statistics
let proposals_for_stats = proposals.clone(); let proposals_for_stats = proposals.clone();
@ -192,7 +189,6 @@ impl GovernanceController {
ctx.insert("user", &user); ctx.insert("user", &user);
} }
println!("============== Loading proposals =================");
// Get proposals from the database // Get proposals from the database
let mut proposals = match get_proposals() { let mut proposals = match get_proposals() {
Ok(props) => props, Ok(props) => props,
@ -202,8 +198,6 @@ impl GovernanceController {
} }
}; };
println!("proposals: {:?}", proposals);
// Filter proposals by status if provided // Filter proposals by status if provided
if let Some(status_filter) = &query.status { if let Some(status_filter) = &query.status {
if !status_filter.is_empty() { if !status_filter.is_empty() {

View File

@ -189,6 +189,7 @@ pub fn submit_vote_on_proposal(
Ok(updated_proposal) Ok(updated_proposal)
} }
#[allow(unused_assignments)]
/// Creates a new governance activity and saves it to the database using OurDB /// Creates a new governance activity and saves it to the database using OurDB
pub fn create_activity( pub fn create_activity(
proposal_id: u32, proposal_id: u32,

View File

@ -54,7 +54,7 @@
</td> </td>
<td> <td>
<small class="text-muted"> <small class="text-muted">
{{ activity.timestamp | date(format="%Y-%m-%d %H:%M") }} {{ activity.created_at | date(format="%Y-%m-%d %H:%M") }}
</small> </small>
</td> </td>
</tr> </tr>

View File

@ -130,7 +130,7 @@
<div> <div>
<div class="d-flex justify-content-between align-items-center"> <div class="d-flex justify-content-between align-items-center">
<strong>{{ activity.user }}</strong> <strong>{{ activity.user }}</strong>
<small class="text-muted">{{ activity.timestamp | date(format="%H:%M") }}</small> <small class="text-muted">{{ activity.created_at | date(format="%H:%M") }}</small>
</div> </div>
<p class="mb-1">{{ activity.action }} on <a <p class="mb-1">{{ activity.action }} on <a
href="/governance/proposals/{{ activity.proposal_id }}">{{ href="/governance/proposals/{{ activity.proposal_id }}">{{