Skip to content

Commit

Permalink
#1946 Filter labels return by platform status
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Apr 12, 2021
1 parent 75420fc commit 04effb7
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions thehive/app/org/thp/thehive/controllers/v1/AdminCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class AdminCtrl @Inject() (
@Named("integrity-check-actor") integrityCheckActor: ActorRef,
integrityCheckOps: immutable.Set[GenIntegrityCheckOps],
db: Database,
schemas: immutable.Set[UpdatableSchema],
implicit val ec: ExecutionContext
) {

Expand Down Expand Up @@ -88,11 +87,37 @@ class AdminCtrl @Inject() (
}
}

val labels = Seq(
"Config",
"ReportTag",
"KeyValue",
"Pattern",
"Case",
"Procedure",
"Alert",
"Dashboard",
"Observable",
"User",
"AnalyzerTemplate",
"Taxonomy",
"CustomField",
"Data",
"Organisation",
"Profile",
"Task",
"Action",
"Log",
"CaseTemplate",
"Audit",
"Tag",
"Job",
"Attachment"
)
def indexStatus: Action[AnyContent] =
entrypoint("Get index status")
.authPermittedRoTransaction(db, Permissions.managePlatform) { _ => graph =>
val indices = schemas.flatMap(_.modelList).collect {
case v: VertexModel => Json.obj("name" -> v.label, "count" -> graph.indexCountQuery(s"""v."_label":${v.label}"""))
val indices = labels.map { label =>
Json.obj("name" -> label, "count" -> graph.indexCountQuery(s"""v."_label":$label"""))
}
val indexCount = Json.obj("name" -> "global", "indices" -> indices)
Success(Results.Ok(Json.obj("index" -> Seq(indexCount))))
Expand Down

0 comments on commit 04effb7

Please sign in to comment.