Skip to content

Commit

Permalink
Wire new filter params to controller
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathonherbert committed Apr 8, 2024
1 parent c01e5f4 commit 27e34aa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
12 changes: 9 additions & 3 deletions apps/rule-manager/app/controllers/RulesController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class RulesController(
.map(toFormError("refresh-sheet"))
_ <- RuleManager.destructivelyPublishRules(dbRules, bucketRuleResource)
} yield {
RuleManager.searchDraftRules(1, None, List.empty)
RuleManager.searchDraftRules(1)
}

maybeWrittenRules match {
Expand Down Expand Up @@ -72,9 +72,15 @@ class RulesController(
}
}

def list(page: Int = 1, word: Option[String] = None, sortBy: List[String] = List.empty) =
def list(
page: Int = 1,
word: Option[String] = None,
tags: List[Int] = List.empty,
ruleTypes: List[String] = List.empty,
sortBy: List[String] = List.empty
) =
APIAuthAction {
Ok(Json.toJson(RuleManager.searchDraftRules(page, word, sortBy)))
Ok(Json.toJson(RuleManager.searchDraftRules(page, word, tags, ruleTypes, sortBy)))
}

def get(id: Int) = APIAuthAction {
Expand Down
10 changes: 8 additions & 2 deletions apps/rule-manager/app/service/RuleManager.scala
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,16 @@ object RuleManager extends Loggable {
}
}

def searchDraftRules(page: Int, queryStr: Option[String], sortBy: List[String])(implicit
def searchDraftRules(
page: Int,
queryStr: Option[String] = None,
tags: List[Int] = List.empty,
ruleTypes: List[String] = List.empty,
sortBy: List[String] = List.empty
)(implicit
session: DBSession = autoSession
): PaginatedResponse[DbRuleDraft] =
DbRuleDraft.searchRules(page, queryStr, sortBy)
DbRuleDraft.searchRules(page, queryStr, tags = tags, ruleTypes = ruleTypes, sortBy = sortBy)

def getDraftDictionaryRules(word: Option[String], page: Int)(implicit
session: DBSession = autoSession
Expand Down
2 changes: 1 addition & 1 deletion apps/rule-manager/conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ POST /api/refresh controllers.RulesController.refresh()
+nocsrf
POST /api/refreshDictionary controllers.RulesController.refreshDictionaryRules()
+nocsrf
GET /api/rules controllers.RulesController.list(page: Int, queryStr: Option[String], sortBy: List[String])
GET /api/rules controllers.RulesController.list(page: Int, queryStr: Option[String], tags: List[Int], ruleTypes: List[String], sortBy: List[String])
+nocsrf
POST /api/rules controllers.RulesController.create()
+nocsrf
Expand Down

0 comments on commit 27e34aa

Please sign in to comment.