Skip to content

Commit

Permalink
#1923 Make the property "Imported" in alerts optimised for index
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Apr 1, 2021
1 parent 14eb881 commit 59a7b1b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
13 changes: 12 additions & 1 deletion thehive/app/org/thp/thehive/controllers/v0/AlertCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,18 @@ class PublicAlert @Inject() (
case _ => Failure(BadRequestError("Invalid custom fields format"))
})
.property("case", db.idMapping)(_.select(_.`case`._id).readonly)
.property("imported", UMapping.boolean)(_.select(_.imported).readonly)
.property("imported", UMapping.boolean)(
_.select(_.imported)
.filter[Boolean]((_, alertTraversal, _, predicate) =>
predicate.fold(
b => if (b) alertTraversal else alertTraversal.empty,
p =>
if (p.getValue) alertTraversal.has(_.caseId)
else alertTraversal.hasNot(_.caseId)
)
)
.readonly
)
.property("importDate", UMapping.date.optional)(_.select(_.importDate).readonly)
.property("computed.handlingDuration", UMapping.long)(_.select(_.handlingDuration).readonly)
.property("computed.handlingDurationInSeconds", UMapping.long)(_.select(_.handlingDuration.math("_ / 1000").domainMap(_.toLong)).readonly)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ class Properties @Inject() (
case _ => Failure(BadRequestError("Invalid custom fields format"))
})
.property("case", db.idMapping)(_.select(_.`case`._id).readonly)
.property("imported", UMapping.boolean)(_.select(_.imported).readonly)
.property("importDate", UMapping.date.optional)(_.select(_.importDate).readonly)
.property("computed.handlingDuration", UMapping.long)(_.select(_.handlingDuration).readonly)
.property("computed.handlingDurationInSeconds", UMapping.long)(_.select(_.handlingDuration.math("_ / 1000").domainMap(_.toLong)).readonly)
Expand Down

0 comments on commit 59a7b1b

Please sign in to comment.