Skip to main content

max / makenotwork

Drop redundant clones in dashboard, health, webhook tests - integrations.rs: dashboard_tab_synckit and _media iterate then move fields into row structs; switch from .iter() with .clone() to .into_iter() taking ownership. - health/mod.rs: same pattern in the response renderer. - stripe/webhook/checkout_helpers.rs: split sums in tests are i64 (Cents inner type), not i32. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Author: Max J. <87768334+MaxJMath@users.noreply.github.com> · 2026-05-15 17:23 UTC
Commit: efef6c18abf7008ecff2f73063e40c9a3911a8b2
Parent: 08d4b15
3 files changed, +36 insertions, -30 deletions
@@ -110,7 +110,7 @@ pub(in crate::routes::pages::dashboard) async fn dashboard_tab_synckit(
110 110 item_titles_batch.into_iter().collect();
111 111
112 112 let mut apps = Vec::with_capacity(db_apps.len());
113 - for app in &db_apps {
113 + for app in db_apps {
114 114 let (device_count, log_entry_count) = stats_map
115 115 .get(&app.id)
116 116 .copied()
@@ -131,14 +131,14 @@ pub(in crate::routes::pages::dashboard) async fn dashboard_tab_synckit(
131 131
132 132 apps.push(SyncAppRow {
133 133 id: app.id.to_string(),
134 - name: app.name.clone(),
134 + name: app.name,
135 135 api_key_masked,
136 136 api_key_full: String::new(),
137 137 is_active: app.is_active,
138 138 device_count,
139 139 log_entry_count,
140 140 created_at: app.created_at.format("%b %d, %Y").to_string(),
141 - slug: app.slug.clone(),
141 + slug: app.slug,
142 142 project_name,
143 143 project_slug,
144 144 item_title,
@@ -168,7 +168,7 @@ pub(in crate::routes::pages::dashboard) async fn dashboard_tab_media(
168 168 let folders = db::media_files::list_folders(&state.db, session_user.id).await?;
169 169
170 170 let files: Vec<MediaFileRow> = db_files
171 - .iter()
171 + .into_iter()
172 172 .map(|f| {
173 173 let cdn_url = format!("{}/{}", cdn_base, f.s3_key);
174 174 let markdown_ref = if f.folder.is_empty() {
@@ -180,11 +180,11 @@ pub(in crate::routes::pages::dashboard) async fn dashboard_tab_media(
180 180 };
181 181 MediaFileRow {
182 182 id: f.id.to_string(),
183 - folder: f.folder.clone(),
184 - filename: f.filename.clone(),
185 - content_type: f.content_type.clone(),
183 + folder: f.folder,
184 + filename: f.filename,
185 + content_type: f.content_type,
186 186 file_size: helpers::format_bytes(f.file_size_bytes),
187 - media_type: f.media_type.clone(),
187 + media_type: f.media_type,
188 188 cdn_url,
189 189 markdown_ref,
190 190 created_at: f.created_at.format("%b %d, %Y").to_string(),
@@ -563,15 +563,18 @@ pub(super) async fn health(
563 563 uptime_24h: data.uptime_24h.map(|v| format!("{:.1}", v)),
564 564 uptime_7d: data.uptime_7d.map(|v| format!("{:.1}", v)),
565 565 last_incident: data.last_incident,
566 - recent_snapshots: data.recent_snapshots.iter().map(|s| HealthSnapshotDisplay {
567 - checked_at: s.checked_at.format("%H:%M:%S UTC").to_string(),
568 - status: s.status.clone(),
569 - status_class: match s.status.as_str() {
566 + recent_snapshots: data.recent_snapshots.into_iter().map(|s| {
567 + let status_class = match s.status.as_str() {
570 568 "operational" => "status-ok".to_string(),
571 569 "degraded" => "status-warn".to_string(),
572 570 _ => "status-error".to_string(),
573 - },
574 - duration_ms: s.check_duration_ms,
571 + };
572 + HealthSnapshotDisplay {
573 + checked_at: s.checked_at.format("%H:%M:%S UTC").to_string(),
574 + status: s.status,
575 + status_class,
576 + duration_ms: s.check_duration_ms,
577 + }
575 578 }).collect(),
576 579 environment: data.environment.to_string(),
577 580 host: data.host,
@@ -580,31 +583,34 @@ pub(super) async fn health(
580 583 db_tests: data.db_tests,
581 584 generated_at: now.format("%Y-%m-%d %H:%M:%S UTC").to_string(),
582 585 pom_available: data.pom_available,
583 - pom_status: data.pom_status.clone(),
584 - pom_status_class: data.pom_status_class.clone(),
586 + pom_status: data.pom_status,
587 + pom_status_class: data.pom_status_class,
585 588 pom_response_time_ms: data.pom_response_time_ms,
586 - pom_checked_at: data.pom_checked_at.clone(),
589 + pom_checked_at: data.pom_checked_at,
587 590 pom_uptime_24h: data.pom_uptime_24h.map(|v| format!("{:.1}", v)),
588 591 pom_uptime_7d: data.pom_uptime_7d.map(|v| format!("{:.1}", v)),
589 - pom_recent: data.pom_recent.iter().map(|s| PomSnapshotDisplay {
590 - checked_at: format_pom_timestamp(&s.checked_at),
591 - status: s.status.clone(),
592 - status_class: match s.status.as_str() {
592 + pom_recent: data.pom_recent.into_iter().map(|s| {
593 + let status_class = match s.status.as_str() {
593 594 "operational" => "status-ok".to_string(),
594 595 "degraded" => "status-warn".to_string(),
595 596 _ => "status-error".to_string(),
596 - },
597 - response_time_ms: s.response_time_ms,
597 + };
598 + PomSnapshotDisplay {
599 + checked_at: format_pom_timestamp(&s.checked_at),
600 + status: s.status,
601 + status_class,
602 + response_time_ms: s.response_time_ms,
603 + }
598 604 }).collect(),
599 - pom_avg_latency: data.pom_avg_latency.clone(),
600 - pom_p95_latency: data.pom_p95_latency.clone(),
605 + pom_avg_latency: data.pom_avg_latency,
606 + pom_p95_latency: data.pom_p95_latency,
601 607 pom_incident_active: data.pom_incident.is_some(),
602 608 pom_incident_status: data.pom_incident.as_ref().map(|i| i.to_status.clone()),
603 609 pom_incident_since: data.pom_incident.as_ref().map(|i| format_pom_timestamp(&i.started_at)),
604 - pom_recent_incidents: data.pom_recent_incidents.iter().map(|i| PomIncidentDisplay {
605 - to_status: i.to_status.clone(),
610 + pom_recent_incidents: data.pom_recent_incidents.into_iter().map(|i| PomIncidentDisplay {
606 611 started_at: format_pom_timestamp(&i.started_at),
607 612 duration: i.duration_secs.map(format_incident_duration).unwrap_or_else(|| "-".to_string()),
613 + to_status: i.to_status,
608 614 }).collect(),
609 615 pom_routes_total: data.pom_routes_total,
610 616 pom_routes_ok: data.pom_routes_ok,
@@ -357,7 +357,7 @@ mod tests {
357 357 let u3 = db::UserId::new();
358 358 let members = vec![member(u1, 33), member(u2, 33), member(u3, 34)];
359 359 let splits = compute_splits(db::Cents::new(100), &members);
360 - let total: i32 = splits.iter().map(|(_, amt, _)| *amt).sum();
360 + let total: i64 = splits.iter().map(|(_, amt, _)| *amt).sum();
361 361 // expected_total = floor(100 * 100 / 100) = 100
362 362 assert_eq!(total, 100);
363 363 }
@@ -397,7 +397,7 @@ mod tests {
397 397 let u3 = db::UserId::new();
398 398 let members = vec![member(u1, 33), member(u2, 33), member(u3, 34)];
399 399 let splits = compute_splits(db::Cents::new(1), &members);
400 - let total: i32 = splits.iter().map(|(_, amt, _)| *amt).sum();
400 + let total: i64 = splits.iter().map(|(_, amt, _)| *amt).sum();
401 401 // expected_total = floor(1*100/100) = 1
402 402 assert_eq!(total, 1);
403 403 }
@@ -409,7 +409,7 @@ mod tests {
409 409 let u3 = db::UserId::new();
410 410 let members = vec![member(u1, 33), member(u2, 33), member(u3, 34)];
411 411 let splits = compute_splits(db::Cents::new(1_000_000), &members);
412 - let total: i32 = splits.iter().map(|(_, amt, _)| *amt).sum();
412 + let total: i64 = splits.iter().map(|(_, amt, _)| *amt).sum();
413 413 // expected_total = floor(1_000_000 * 100 / 100) = 1_000_000
414 414 assert_eq!(total, 1_000_000);
415 415 // Verify individual amounts are reasonable