Fix info about parcel with empty states
Some checks failed
continuous-integration/drone/push Build was killed

This commit is contained in:
Pavel Kachalouski
2019-11-06 22:10:30 +01:00
parent f8f1752d7c
commit 494bf71e61

View File

@@ -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) {