Due to a scheduled upgrade to version 14.10, GitLab will be unavailabe on Monday 30.05., from 19:00 until 20:00.

Unverified Commit 8f98a84e authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files

check timestamp parsing

parent 4c8dda2b
Pipeline #17827 passed with stages
in 4 minutes and 42 seconds
...@@ -23,10 +23,13 @@ import java.util.Calendar ...@@ -23,10 +23,13 @@ import java.util.Calendar
import ch.memobase.models.Report import ch.memobase.models.Report
import org.apache.kafka.clients.consumer.ConsumerRecord import org.apache.kafka.clients.consumer.ConsumerRecord
import org.apache.logging.log4j.scala.Logging
import scala.collection.JavaConverters._ import scala.collection.JavaConverters._
import scala.util.{Failure, Success, Try}
trait MsgFilter { trait MsgFilter {
self: Logging =>
private val dateFormatter = new SimpleDateFormat("YYYY-MM-dd'T'HH:mm:ss.SSS") private val dateFormatter = new SimpleDateFormat("YYYY-MM-dd'T'HH:mm:ss.SSS")
...@@ -86,18 +89,27 @@ trait MsgFilter { ...@@ -86,18 +89,27 @@ trait MsgFilter {
Report(rec.value()).id == recordId Report(rec.value()).id == recordId
private val buildCreatedAfterFilter: String => FilterFun = private val buildCreatedAfterFilter: String => FilterFun =
timestamp => rec => { timestamp => rec =>
val recordTimestamp = Report(rec.value()).timestamp Try {
recordTimestamp == timestamp || dateFormatter.parse(timestamp).after(dateFormatter.parse(Report(rec.value()).timestamp))
dateFormatter.parse(timestamp).after(dateFormatter.parse(recordTimestamp)) } match {
} case Success(res) => res
case Failure(_) =>
logger.warn(s"Parsing of timestamp ${Report(rec.value()).timestamp} failed! Ignoring record")
false
}
private val buildCreatedBeforeFilter: String => FilterFun = private val buildCreatedBeforeFilter: String => FilterFun =
timestamp => rec => { timestamp => rec =>
val recordTimestamp = Report(rec.value()).timestamp Try {
recordTimestamp == timestamp || dateFormatter.parse(timestamp).before(dateFormatter.parse(Report(rec.value()).timestamp))
dateFormatter.parse(timestamp).before(dateFormatter.parse(recordTimestamp)) } match {
} case Success(res) => res
case Failure(_) =>
logger.warn(s"Parsing of timestamp ${Report(rec.value()).timestamp} failed! Ignoring record")
false
}
private val buildStatusFilter: String => FilterFun = private val buildStatusFilter: String => FilterFun =
status => rec => Report(rec.value()).status == status status => rec => Report(rec.value()).status == status
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment