hide commission entries after two inactive weeks (fixes philomena-dev/philomena#31)

This commit is contained in:
byte[] 2020-12-12 16:38:56 -05:00
parent 07778d1680
commit dd535b5af2

View file

@ -2,6 +2,7 @@ defmodule PhilomenaWeb.CommissionController do
use PhilomenaWeb, :controller use PhilomenaWeb, :controller
alias Philomena.Commissions.{Item, Commission} alias Philomena.Commissions.{Item, Commission}
alias Philomena.UserIps.UserIp
alias Philomena.Repo alias Philomena.Repo
import Ecto.Query import Ecto.Query
@ -68,6 +69,9 @@ defmodule PhilomenaWeb.CommissionController do
where: c.commission_items_count > 0, where: c.commission_items_count > 0,
inner_join: ci in Item, inner_join: ci in Item,
on: ci.commission_id == c.id, on: ci.commission_id == c.id,
inner_join: ui in UserIp,
on: ui.user_id == c.user_id,
where: ui.updated_at >= ago(2, "week"),
group_by: c.id, group_by: c.id,
order_by: [asc: fragment("random()")], order_by: [asc: fragment("random()")],
preload: [user: [awards: :badge], items: [example_image: [tags: :aliases]]] preload: [user: [awards: :badge], items: [example_image: [tags: :aliases]]]