mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
update query param in conn
This commit is contained in:
parent
1bec3e0caa
commit
7be7ca8303
4 changed files with 10 additions and 4 deletions
|
@ -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 =
|
||||||
|
|
|
@ -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(
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue