Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
memoriav
Memobase 2020
services
Deletion Components
Import Process Delete
Commits
8f98a84e
Unverified
Commit
8f98a84e
authored
Nov 25, 2020
by
Sebastian Schüpbach
Browse files
check timestamp parsing
parent
4c8dda2b
Pipeline
#17827
passed with stages
in 4 minutes and 42 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/scala/ch/memobase/MsgFilter.scala
View file @
8f98a84e
...
...
@@ -23,10 +23,13 @@ import java.util.Calendar
import
ch.memobase.models.Report
import
org.apache.kafka.clients.consumer.ConsumerRecord
import
org.apache.logging.log4j.scala.Logging
import
scala.collection.JavaConverters._
import
scala.util.
{
Failure
,
Success
,
Try
}
trait
MsgFilter
{
self
:
Logging
=>
private
val
dateFormatter
=
new
SimpleDateFormat
(
"YYYY-MM-dd'T'HH:mm:ss.SSS"
)
...
...
@@ -86,18 +89,27 @@ trait MsgFilter {
Report
(
rec
.
value
()).
id
==
recordId
private
val
buildCreatedAfterFilter
:
String
=>
FilterFun
=
timestamp
=>
rec
=>
{
val
recordTimestamp
=
Report
(
rec
.
value
()).
timestamp
recordTimestamp
==
timestamp
||
dateFormatter
.
parse
(
timestamp
).
after
(
dateFormatter
.
parse
(
recordTimestamp
))
}
timestamp
=>
rec
=>
Try
{
dateFormatter
.
parse
(
timestamp
).
after
(
dateFormatter
.
parse
(
Report
(
rec
.
value
()).
timestamp
))
}
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
=
timestamp
=>
rec
=>
{
val
recordTimestamp
=
Report
(
rec
.
value
()).
timestamp
recordTimestamp
==
timestamp
||
dateFormatter
.
parse
(
timestamp
).
before
(
dateFormatter
.
parse
(
recordTimestamp
))
}
timestamp
=>
rec
=>
Try
{
dateFormatter
.
parse
(
timestamp
).
before
(
dateFormatter
.
parse
(
Report
(
rec
.
value
()).
timestamp
))
}
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
=
status
=>
rec
=>
Report
(
rec
.
value
()).
status
==
status
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment