update query param in conn

This commit is contained in:
byte[] 2019-12-02 09:37:01 -05:00
parent 1bec3e0caa
commit 7be7ca8303
4 changed files with 10 additions and 4 deletions

View file

@ -7,6 +7,9 @@ defmodule PhilomenaWeb.CommentController do
def index(conn, params) do def index(conn, params) do
cq = params["cq"] || "created_at.gte:1 week ago" cq = params["cq"] || "created_at.gte:1 week ago"
params = Map.put(conn.params, "cq", cq)
conn = Map.put(conn, :params, params)
{:ok, query} = Query.compile(conn.assigns.current_user, cq) {:ok, query} = Query.compile(conn.assigns.current_user, cq)
comments = comments =

View file

@ -5,9 +5,12 @@ defmodule PhilomenaWeb.PostController do
import Ecto.Query import Ecto.Query
def index(conn, params) do def index(conn, params) do
cq = params["pq"] || "created_at.gte:1 week ago" pq = params["pq"] || "created_at.gte:1 week ago"
{:ok, query} = Query.compile(conn.assigns.current_user, cq) params = Map.put(conn.params, "pq", pq)
conn = Map.put(conn, :params, params)
{:ok, query} = Query.compile(conn.assigns.current_user, pq)
posts = posts =
Post.search_records( Post.search_records(

View file

@ -2,7 +2,7 @@ h1 Comments
= form_for :comments, Routes.comment_path(@conn, :index), [method: "get", class: "hform", enforce_utf8: false], fn f -> = form_for :comments, Routes.comment_path(@conn, :index), [method: "get", class: "hform", enforce_utf8: false], fn f ->
.field .field
= text_input f, :cq, name: :cq, value: @conn.params["cq"] || "created_at.gte:1 week ago", class: "input hform__text", placeholder: "Search comments", autocapitalize: "none" = text_input f, :cq, name: :cq, value: @conn.params["cq"], class: "input hform__text", placeholder: "Search comments", autocapitalize: "none"
= submit "Search", class: "hform__button button", data: [disable_with: false] = submit "Search", class: "hform__button button", data: [disable_with: false]
.fieldlabel .fieldlabel

View file

@ -2,7 +2,7 @@ h1 Posts
= form_for :posts, Routes.post_path(@conn, :index), [method: "get", class: "hform", enforce_utf8: false], fn f -> = form_for :posts, Routes.post_path(@conn, :index), [method: "get", class: "hform", enforce_utf8: false], fn f ->
.field .field
= text_input f, :pq, name: :pq, value: @conn.params["pq"] || "created_at.gte:1 week ago", class: "input hform__text", placeholder: "Search posts", autocapitalize: "none" = text_input f, :pq, name: :pq, value: @conn.params["pq"], class: "input hform__text", placeholder: "Search posts", autocapitalize: "none"
= submit "Search", class: "hform__button button", data: [disable_with: false] = submit "Search", class: "hform__button button", data: [disable_with: false]
.fieldlabel .fieldlabel