@@ -33,30 +33,57 @@ case object PreMatch extends MatchStatus { val status = "PRE_MATCH" }
3333case object FirstHalf extends MatchStatus { val status = " FIRST_HALF" }
3434case object HalfTime extends MatchStatus { val status = " HALF_TIME" }
3535case object SecondHalf extends MatchStatus { val status = " SECOND_HALF" }
36+ case object ExtraTimeToBePlayed extends MatchStatus { val status = " EXTRA_TIME_TO_BE_PLAYED" }
3637case object ExtraTimeFirstHalf extends MatchStatus { val status = " EXTRA_TIME_FIRST_HALF" }
3738case object ExtraTimeHalfTime extends MatchStatus { val status = " EXTRA_TIME_HALF_TIME" }
3839case object ExtraTimeSecondHalf extends MatchStatus { val status = " EXTRA_TIME_SECOND_HALF" }
40+ case object PenaltiesToBePlayed extends MatchStatus { val status = " PENALTIES_TO_BE_PLAYED" }
3941case object Penalties extends MatchStatus { val status = " PENALTIES" }
4042case object FullTime extends MatchStatus { val status = " FULL_TIME" }
4143case object Postponed extends MatchStatus { val status = " POSTPONED" }
44+ case object Suspended extends MatchStatus { val status = " SUSPENDED" }
4245case object Abandoned extends MatchStatus { val status = " ABANDONED" }
46+ case object Resumed extends MatchStatus { val status = " RESUMED" }
47+ case object Cancelled extends MatchStatus { val status = " CANCELLED" }
4348// @formatter:on
4449
4550object MatchStatus {
46- def fromString (s : String ): MatchStatus = s match {
47- case " Pre-match" | " prematch" => PreMatch
48- case " MatchInProgress" | " 1st Half" | " first_half" => FirstHalf
49- case " HalfTime" | " Half Time" | " half_time" => HalfTime
50- case " 2nd Half" | " second_half" => SecondHalf
51- case " Extra Time" | " ET 1st Half" => ExtraTimeFirstHalf
52- case " ET Half Time" => ExtraTimeHalfTime
53- case " ET 2nd Half" => ExtraTimeSecondHalf
54- case " Penalties" => Penalties
55- case " MatchComplete" | " MC" | " Full Time" | " Result" => FullTime
56- case " Postponed" => Postponed
57- case " Abandoned" => Abandoned
58- case _ => Scheduled
59- }
51+ def fromString (s : String ): MatchStatus = statuses.getOrElse(s, Scheduled )
52+
53+ // How PA match status are handled here differs from push notification mappings
54+ private val statuses : Map [String , MatchStatus ] = Map (
55+ (" Fixture" , PreMatch ), //
56+ (" -" , PreMatch ), // seen in the wild
57+ (" New" , PreMatch ), //
58+
59+ (" KO" , FirstHalf ), // The Match has started (Kicked Off).
60+
61+ (" HT" , HalfTime ), // The Referee has blown the whistle for Half Time.
62+
63+ (" SHS" , SecondHalf ), // The Second Half of the Match has Started.
64+
65+ (" FT" , FullTime ), // The Referee has blown the whistle for Full Time.
66+ (" Result" , FullTime ), // The Result is official.
67+ (" MC" , FullTime ), // Match has been Completed.
68+
69+ (" FTET" , ExtraTimeToBePlayed ), // Full Time, Extra Time it to be played.
70+ (" ETS" , ExtraTimeFirstHalf ), // Extra Time has Started.
71+ (" ETHT" , ExtraTimeHalfTime ), // Extra Time Half Time has been called.
72+ (" ETSHS" , ExtraTimeSecondHalf ), // Extra Time, Second Half has Started.
73+ (" ETFT" , ExtraTimeSecondHalf ), // Extra Time, Full Time has been blown.
74+
75+ (" FTPT" , PenaltiesToBePlayed ), // Full Time, Penalties are To be played.
76+ (" ETFTPT" , PenaltiesToBePlayed ), // Extra Time, Full Time, Penalties are To be played.
77+ (" PT" , Penalties ), // Penalty ShooT Out has started.
78+ (" PTFT" , Penalties ), // Penalty ShooT Full Time.
79+
80+ // edge cases
81+ (" Suspended" , Suspended ), // Match has been Suspended.
82+ (" Resumed" , Resumed ), // Match has been Resumed. // todo can match phase be determined by match minute?
83+ (" Abandoned" , Abandoned ), // Match has been Abandoned.
84+ (" Postponed" , Postponed ), // A Match has been Postponed.
85+ (" Cancelled" , Cancelled ) // A Match has been Cancelled.
86+ )
6087}
6188
6289case class Competition (
@@ -87,13 +114,13 @@ case class FootballMatchContentState(
87114 awayTeam : TeamState ,
88115 competition : Competition ,
89116 commentary : Option [String ] = None ,
90- lineupsAvailable : Option [ Boolean ] = None ,
117+ lineupsAvailable : Boolean = false ,
91118 currentMinute : Option [Int ] = None ,
92119 currentPeriodStartTime : Option [Long ] = None ,
93- articleUrl : Option [String ] = None
120+ articleUrl : Option [String ] = None ,
121+ matchInfoUrl : String
94122) extends ContentState
95123
96-
97124object FootballContentJsonFormats {
98125 // MatchStatus format must be defined first since FootballMatchContentState depends on it
99126 implicit val matchStatusFormat : Format [MatchStatus ] = Format (
@@ -105,13 +132,18 @@ object FootballContentJsonFormats {
105132 case " FIRST_HALF" => JsSuccess (FirstHalf )
106133 case " HALF_TIME" => JsSuccess (HalfTime )
107134 case " SECOND_HALF" => JsSuccess (SecondHalf )
135+ case " EXTRA_TIME_TO_BE_PLAYED" => JsSuccess (ExtraTimeToBePlayed )
108136 case " EXTRA_TIME_FIRST_HALF" => JsSuccess (ExtraTimeFirstHalf )
109137 case " EXTRA_TIME_HALF_TIME" => JsSuccess (ExtraTimeHalfTime )
110138 case " EXTRA_TIME_SECOND_HALF" => JsSuccess (ExtraTimeSecondHalf )
139+ case " PENALTIES_TO_BE_PLAYED" => JsSuccess (PenaltiesToBePlayed )
111140 case " PENALTIES" => JsSuccess (Penalties )
112141 case " FULL_TIME" => JsSuccess (FullTime )
142+ case " SUSPENDED" => JsSuccess (Suspended )
143+ case " RESUMED" => JsSuccess (Resumed )
113144 case " POSTPONED" => JsSuccess (Postponed )
114145 case " ABANDONED" => JsSuccess (Abandoned )
146+ case " CANCELLED" => JsSuccess (Cancelled )
115147 case other => JsError (s " Unknown match status: $other" )
116148 }
117149 case _ => JsError (" Expected a JSON string for MatchStatus" )
0 commit comments