add order by statement to gallery list

This commit is contained in:
byte[] 2019-12-21 17:57:29 -05:00
parent c8747a0523
commit 7abb5921b9

View file

@ -124,6 +124,7 @@ defmodule PhilomenaWeb.ImageController do
Gallery
|> where(creator_id: ^user.id)
|> join(:inner, [g], gi in Interaction, on: g.id == gi.gallery_id and gi.image_id == ^image.id)
|> order_by(desc: :created_at)
|> Repo.all()
image_gallery_ids = Enum.map(image_galleries, & &1.id)
@ -132,6 +133,7 @@ defmodule PhilomenaWeb.ImageController do
Gallery
|> where(creator_id: ^user.id)
|> where([g], g.id not in ^image_gallery_ids)
|> order_by(desc: :created_at)
|> Repo.all()
{user_galleries, image_galleries}