mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-04-20 02:03:59 +02:00
Merge 14a3e21ae0
into 78550a6322
This commit is contained in:
commit
f4b35cc347
3 changed files with 21 additions and 6 deletions
lib/philomena_web
|
@ -20,10 +20,8 @@ defmodule PhilomenaWeb.ActivityController do
|
|||
def index(conn, _params) do
|
||||
user = conn.assigns.current_user
|
||||
|
||||
{:ok, {images, _tags}} =
|
||||
ImageLoader.search_string(
|
||||
conn,
|
||||
"created_at.lte:3 minutes ago, -thumbnails_generated:false",
|
||||
{images, _tags} =
|
||||
ImageLoader.default_query(conn,
|
||||
pagination: %{conn.assigns.image_pagination | page_number: 1}
|
||||
)
|
||||
|
||||
|
|
|
@ -37,8 +37,7 @@ defmodule PhilomenaWeb.ImageController do
|
|||
plug PhilomenaWeb.AdvertPlug when action in [:show]
|
||||
|
||||
def index(conn, _params) do
|
||||
{:ok, {images, _tags}} =
|
||||
ImageLoader.search_string(conn, "created_at.lte:3 minutes ago, -thumbnails_generated:false")
|
||||
{images, _tags} = ImageLoader.default_query(conn)
|
||||
|
||||
images = Search.search_records(images, preload(Image, [:sources, tags: :aliases]))
|
||||
|
||||
|
|
|
@ -7,6 +7,24 @@ defmodule PhilomenaWeb.ImageLoader do
|
|||
alias Philomena.Repo
|
||||
import Ecto.Query
|
||||
|
||||
def default_query(conn, options \\ [])
|
||||
|
||||
def default_query(conn, options) when conn.assigns.current_user.role != "user",
|
||||
do: query(conn, %{match_all: %{}}, options)
|
||||
|
||||
def default_query(conn, options),
|
||||
do:
|
||||
query(
|
||||
conn,
|
||||
%{
|
||||
bool: %{
|
||||
must: [%{range: %{created_at: %{lte: "now-3m"}}}],
|
||||
must_not: [%{term: %{thumbnails_generated: false}}]
|
||||
}
|
||||
},
|
||||
options
|
||||
)
|
||||
|
||||
# sobelow_skip ["SQL.Query"]
|
||||
def search_string(conn, search_string, options \\ []) do
|
||||
user = conn.assigns.current_user
|
||||
|
|
Loading…
Add table
Reference in a new issue