Fix info about parcel with empty states
Some checks failed
continuous-integration/drone/push Build was killed
Some checks failed
continuous-integration/drone/push Build was killed
This commit is contained in:
@@ -74,11 +74,12 @@ object CzechPostDeliveryCheck {
|
||||
}
|
||||
|
||||
def latestStatePrint(parcelId: String): String = {
|
||||
val state = latestState
|
||||
s"$parcelId ($comment) - ${printDateFormat.format(czechPostDateFormat.parse(state.date))} - ${state.text}"
|
||||
latestState
|
||||
.map(state => s"$parcelId ($comment) - ${printDateFormat.format(czechPostDateFormat.parse(state.date))} - ${state.text}")
|
||||
.getOrElse(s"$parcelId ($comment) - NO INFO")
|
||||
}
|
||||
|
||||
private def latestState: Entities.State = states.toSeq.maxBy(state => czechPostDateFormat.parse(state.date))
|
||||
private def latestState: Option[Entities.State] = states.toSeq.maxByOption(state => czechPostDateFormat.parse(state.date))
|
||||
}
|
||||
|
||||
case class State(parcelStates: Map[String, Parcel] = Map.empty) {
|
||||
|
||||
Reference in New Issue
Block a user