mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-30 14:57:59 +01:00
Use compile with opts for comment queries
This commit is contained in:
parent
097158bbbb
commit
fc2ab285c7
3 changed files with 5 additions and 4 deletions
|
@ -92,7 +92,8 @@ defmodule Philomena.Comments.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
|
||||||
|
|
|
@ -10,7 +10,7 @@ defmodule PhilomenaWeb.Api.Json.Search.CommentController do
|
||||||
user = conn.assigns.current_user
|
user = conn.assigns.current_user
|
||||||
filter = conn.assigns.current_filter
|
filter = conn.assigns.current_filter
|
||||||
|
|
||||||
case Query.compile(user, params["q"] || "") do
|
case Query.compile(params["q"], user: user) do
|
||||||
{:ok, query} ->
|
{:ok, query} ->
|
||||||
comments =
|
comments =
|
||||||
Comment
|
Comment
|
||||||
|
|
|
@ -13,8 +13,8 @@ defmodule PhilomenaWeb.CommentController do
|
||||||
conn = Map.put(conn, :params, params)
|
conn = Map.put(conn, :params, params)
|
||||||
user = conn.assigns.current_user
|
user = conn.assigns.current_user
|
||||||
|
|
||||||
user
|
cq
|
||||||
|> Query.compile(cq)
|
|> Query.compile(user: user)
|
||||||
|> render_index(conn, user)
|
|> render_index(conn, user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue