mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-30 14:57:59 +01:00
Use compile with opts for post queries
This commit is contained in:
parent
e9eb638d79
commit
476363d4f7
3 changed files with 5 additions and 4 deletions
|
@ -90,7 +90,8 @@ defmodule Philomena.Posts.Query do
|
|||
|> Parser.parse(query_string, context)
|
||||
end
|
||||
|
||||
def compile(user, query_string) do
|
||||
def compile(query_string, opts \\ []) do
|
||||
user = Keyword.get(opts, :user)
|
||||
query_string = query_string || ""
|
||||
|
||||
case user do
|
||||
|
|
|
@ -9,7 +9,7 @@ defmodule PhilomenaWeb.Api.Json.Search.PostController do
|
|||
def index(conn, params) do
|
||||
user = conn.assigns.current_user
|
||||
|
||||
case Query.compile(user, params["q"] || "") do
|
||||
case Query.compile(params["q"], user: user) do
|
||||
{:ok, query} ->
|
||||
posts =
|
||||
Post
|
||||
|
|
|
@ -13,8 +13,8 @@ defmodule PhilomenaWeb.PostController do
|
|||
conn = Map.put(conn, :params, params)
|
||||
user = conn.assigns.current_user
|
||||
|
||||
user
|
||||
|> Query.compile(pq)
|
||||
pq
|
||||
|> Query.compile(user: user)
|
||||
|> render_index(conn, user)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue