Skip to content

Commit

Permalink
#1670 Rename tagAutoComplete query and sort freetags
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Mar 4, 2021
1 parent d96842a commit a37185b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions thehive/app/org/thp/thehive/controllers/v0/TagCtrl.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.thp.thehive.controllers.v0

import org.apache.tinkerpop.gremlin.process.traversal.Order
import org.apache.tinkerpop.gremlin.structure.Vertex
import org.thp.scalligraph.EntityIdOrName
import org.thp.scalligraph.controllers.{Entrypoint, Renderer}
Expand Down Expand Up @@ -57,12 +58,12 @@ class PublicTag @Inject() (tagSrv: TagSrv, organisationSrv: OrganisationSrv) ext
Query[Traversal.V[Tag], Traversal.V[Tag]]("fromObservable", (tagSteps, _) => tagSteps.fromObservable),
Query[Traversal.V[Tag], Traversal.V[Tag]]("fromAlert", (tagSteps, _) => tagSteps.fromAlert),
Query.initWithParam[TagHint, Traversal[String, Vertex, Converter[String, Vertex]]](
"TagAutoComplete",
"tagAutoComplete",
(tagHint, graph, authContext) =>
tagHint
.freeTag
.fold(tagSrv.startTraversal(graph).autoComplete(tagHint.namespace, tagHint.predicate, tagHint.value)(authContext).visible(authContext))(
tagSrv.startTraversal(graph).autoComplete(organisationSrv, _)(authContext)
tagSrv.startTraversal(graph).autoComplete(organisationSrv, _)(authContext).sort(_.by("predicate", Order.asc))
)
.merge(tagHint.limit)(_.limit(_))
.displayName
Expand Down
5 changes: 3 additions & 2 deletions thehive/app/org/thp/thehive/controllers/v1/TagCtrl.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.thp.thehive.controllers.v1

import org.apache.tinkerpop.gremlin.process.traversal.Order
import org.apache.tinkerpop.gremlin.structure.Vertex
import org.thp.scalligraph.EntityIdOrName
import org.thp.scalligraph.controllers.{Entrypoint, FieldsParser}
Expand Down Expand Up @@ -41,12 +42,12 @@ class TagCtrl @Inject() (
override val extraQueries: Seq[ParamQuery[_]] = Seq(
Query[Traversal.V[Tag], Traversal.V[Tag]]("freetags", (tagSteps, authContext) => tagSteps.freetags(organisationSrv)(authContext)),
Query.initWithParam[TagHint, Traversal[String, Vertex, Converter[String, Vertex]]](
"TagAutoComplete",
"tagAutoComplete",
(tagHint, graph, authContext) =>
tagHint
.freeTag
.fold(tagSrv.startTraversal(graph).autoComplete(tagHint.namespace, tagHint.predicate, tagHint.value)(authContext).visible(authContext))(
tagSrv.startTraversal(graph).autoComplete(organisationSrv, _)(authContext)
tagSrv.startTraversal(graph).autoComplete(organisationSrv, _)(authContext).sort(_.by("predicate", Order.asc))
)
.merge(tagHint.limit)(_.limit(_))
.displayName
Expand Down

0 comments on commit a37185b

Please sign in to comment.