Commit Diff


commit - 7d5acdf47d9b7afacd44d71c64af0c00e3782a11
commit + a9e4a3e6c6d1734057c2f241bbca4b41702dff25
blob - 719bad90378963b1ed0d9e3c82ba60bea3d01b91
blob + 347f29874df4b5a0b632dff6605f571c35d709cf
--- src/display.rs
+++ src/display.rs
@@ -1,6 +1,6 @@
 use crate::models::{Match, StandingsResponse};
 use chrono::Utc;
-use prettytable::{format, Cell, Row, Table};
+use prettytable::{Cell, Row, Table, format};
 
 const STATUS_ICONS: &[(&str, &str)] = &[("FINISHED", "✓"), ("SCHEDULED", "⏰"), ("IN_PLAY", "▶")];
 
@@ -115,8 +115,9 @@ pub fn display_table(matches: &[Match]) {
 }
 
 pub fn display_standings(standings_response: StandingsResponse) {
+    let mut printed = false;
     for standing in standings_response.standings {
-        if standing.table.is_empty() {
+        if standing.table.is_empty() || printed {
             continue;
         }
 
@@ -158,6 +159,7 @@ pub fn display_standings(standings_response: Standings
         }
 
         table.printstd();
+        printed = true;
     }
 }
 
@@ -170,14 +172,14 @@ mod tests {
     fn create_match(date: Option<chrono::DateTime<Utc>>, home: &str, away: &str) -> Match {
         Match {
             utc_date: date,
-            status: "SCHEDULED".to_string(),
+            status: Some("SCHEDULED".to_string()),
             matchday: Some(1),
             home_team: Team {
-                name: home.to_string(),
+                name: Some(home.to_string()),
                 tla: Some(home[..3].to_string()),
             },
             away_team: Team {
-                name: away.to_string(),
+                name: Some(away.to_string()),
                 tla: Some(away[..3].to_string()),
             },
             score: Score {
@@ -219,7 +221,7 @@ mod tests {
 
         let result = filter_matches(matches, None, false);
         assert_eq!(result.len(), 1);
-        assert_eq!(result[0].home_team.name, "Liverpool");
+        assert_eq!(result[0].home_team.name, Some("Liverpool".to_string()));
     }
 
     #[test]
@@ -242,7 +244,7 @@ mod tests {
 
         let matches = vec![create_match(Some(future), "Arsenal", "Chelsea")];
 
-        let result = filter_matches(matches, Some("arsenal"), true);
+        let result = filter_matches(matches.clone(), Some("arsenal"), true);
         assert_eq!(result.len(), 1);
 
         let result = filter_matches(matches, Some("ARSENAL"), true);
blob - 866821ee12693f689f6ba8d2ab405828d54d8f6e
blob + 51c9addaf1d8677e06267a74af7c42de3076a433
--- src/models.rs
+++ src/models.rs
@@ -1,7 +1,7 @@
 use chrono::{DateTime, Utc};
 use serde::Deserialize;
 
-#[derive(Debug, Deserialize)]
+#[derive(Debug, Deserialize, Clone)]
 #[serde(rename_all = "camelCase")]
 pub struct Match {
     pub utc_date: Option<DateTime<Utc>>,
@@ -12,35 +12,35 @@ pub struct Match {
     pub score: Score,
 }
 
-#[derive(Debug, Deserialize)]
+#[derive(Debug, Deserialize, Clone)]
 pub struct Team {
     pub name: Option<String>,
     pub tla: Option<String>,
 }
 
-#[derive(Debug, Deserialize)]
+#[derive(Debug, Deserialize, Clone)]
 #[serde(rename_all = "camelCase")]
 pub struct Score {
     pub full_time: ScoreDetail,
 }
 
-#[derive(Debug, Deserialize, Default)]
+#[derive(Debug, Deserialize, Default, Clone)]
 pub struct ScoreDetail {
     pub home: Option<u32>,
     pub away: Option<u32>,
 }
 
-#[derive(Debug, Deserialize)]
+#[derive(Debug, Deserialize, Clone)]
 pub struct MatchesResponse {
     pub matches: Vec<Match>,
 }
 
-#[derive(Debug, Deserialize)]
+#[derive(Debug, Deserialize, Clone)]
 pub struct StandingsResponse {
     pub standings: Vec<Standing>,
 }
 
-#[derive(Debug, Deserialize)]
+#[derive(Debug, Deserialize, Clone)]
 pub struct Standing {
     #[serde(rename = "type")]
     #[allow(dead_code)]
@@ -53,7 +53,7 @@ pub struct Standing {
     pub table: Vec<TableEntry>,
 }
 
-#[derive(Debug, Deserialize)]
+#[derive(Debug, Deserialize, Clone)]
 #[serde(rename_all = "camelCase")]
 pub struct TableEntry {
     pub position: u32,
@@ -68,7 +68,7 @@ pub struct TableEntry {
     pub goal_difference: i32,
 }
 
-#[derive(Debug, Deserialize)]
+#[derive(Debug, Deserialize, Clone)]
 pub struct TeamInfo {
     pub name: String,
 }