mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
fix datetime parsing
This commit is contained in:
parent
9b87f9a07a
commit
8b79f5808f
4 changed files with 7 additions and 7 deletions
|
@ -5,7 +5,7 @@ defmodule Philomena.Comments.Query do
|
|||
case Integer.parse(data) do
|
||||
{int, _rest} ->
|
||||
{
|
||||
:ok,
|
||||
:ok,
|
||||
%{
|
||||
bool: %{
|
||||
must: [
|
||||
|
@ -23,7 +23,7 @@ defmodule Philomena.Comments.Query do
|
|||
|
||||
def author_transform(_ctx, data) do
|
||||
{
|
||||
:ok,
|
||||
:ok,
|
||||
%{
|
||||
bool: %{
|
||||
must: [
|
||||
|
|
|
@ -5,7 +5,7 @@ defmodule PhilomenaWeb.CommentController do
|
|||
import Ecto.Query
|
||||
|
||||
def index(conn, params) do
|
||||
cq = params["cq"] || "created_at.gt:1 week ago"
|
||||
cq = params["cq"] || "created_at.gte:1 week ago"
|
||||
|
||||
{:ok, query} = Query.compile(conn.assigns.current_user, cq)
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ h1 Comments
|
|||
|
||||
= form_for :comments, Routes.comment_path(@conn, :index), [method: "get", class: "hform", enforce_utf8: false], fn f ->
|
||||
.field
|
||||
= text_input f, :cq, name: :cq, value: @conn.params["cq"] || "created_at.gt:1 week ago", class: "input hform__text", placeholder: "Search comments", autocapitalize: "none"
|
||||
= 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"
|
||||
= submit "Search", class: "hform__button button", data: [disable_with: false]
|
||||
|
||||
.fieldlabel
|
||||
|
|
|
@ -91,10 +91,10 @@ defmodule Search.DateParser do
|
|||
end
|
||||
|
||||
defp relative_datetime([count, scale]) do
|
||||
now = NaiveDateTime.utc_now()
|
||||
now = DateTime.utc_now()
|
||||
|
||||
lower = NaiveDateTime.add(now, count * -scale, :second)
|
||||
upper = NaiveDateTime.add(now, (count - 1) * -scale, :second)
|
||||
lower = DateTime.add(now, count * -scale, :second)
|
||||
upper = DateTime.add(now, (count - 1) * -scale, :second)
|
||||
|
||||
[lower, upper]
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue