mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-20 06:37:59 +01:00
Use compile with opts for filter queries
This commit is contained in:
parent
fc2ab285c7
commit
e9eb638d79
3 changed files with 5 additions and 4 deletions
|
@ -33,7 +33,8 @@ defmodule Philomena.Filters.Query do
|
||||||
|> Parser.parse(query_string, context)
|
|> Parser.parse(query_string, context)
|
||||||
end
|
end
|
||||||
|
|
||||||
def compile(user, query_string) do
|
def compile(query_string, opts \\ []) do
|
||||||
|
user = Keyword.get(opts, :user)
|
||||||
query_string = query_string || ""
|
query_string = query_string || ""
|
||||||
|
|
||||||
case user do
|
case user do
|
||||||
|
|
|
@ -9,7 +9,7 @@ defmodule PhilomenaWeb.Api.Json.Search.FilterController do
|
||||||
def index(conn, params) do
|
def index(conn, params) do
|
||||||
user = conn.assigns.current_user
|
user = conn.assigns.current_user
|
||||||
|
|
||||||
case Query.compile(user, params["q"] || "") do
|
case Query.compile(params["q"], user: user) do
|
||||||
{:ok, query} ->
|
{:ok, query} ->
|
||||||
filters =
|
filters =
|
||||||
Filter
|
Filter
|
||||||
|
|
|
@ -13,8 +13,8 @@ defmodule PhilomenaWeb.FilterController do
|
||||||
def index(conn, %{"fq" => fq}) do
|
def index(conn, %{"fq" => fq}) do
|
||||||
user = conn.assigns.current_user
|
user = conn.assigns.current_user
|
||||||
|
|
||||||
user
|
fq
|
||||||
|> Query.compile(fq)
|
|> Query.compile(user: user)
|
||||||
|> render_index(conn, user)
|
|> render_index(conn, user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue