Skip to content

Commit

Permalink
sort on updated_at value, #30
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonLab committed Feb 5, 2019
1 parent 7d46a3a commit 34c76da
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/alog.ex
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ defmodule Alog do
from(
m in __MODULE__,
where: m.entry_id == ^entry_id,
order_by: [desc: :inserted_at],
order_by: [desc: :updated_at],
limit: 1,
select: m
)
Expand Down Expand Up @@ -179,7 +179,7 @@ defmodule Alog do
end
end)
end).()
|> order_by([m], desc: m.inserted_at)
|> order_by([m], desc: m.updated_at)
|> distinct([m], m.entry_id)
|> select([m], m)

Expand Down Expand Up @@ -250,7 +250,7 @@ defmodule Alog do
sub =
from(m in __MODULE__,
distinct: m.entry_id,
order_by: [desc: :inserted_at],
order_by: [desc: :updated_at],
select: m
)

Expand Down Expand Up @@ -345,7 +345,7 @@ defmodule Alog do
sub =
from(mod in Map.get(module.__schema__(:association, assoc), :queryable),
distinct: mod.entry_id,
order_by: [desc: :inserted_at],
order_by: [desc: :updated_at],
select: mod
)

Expand Down

0 comments on commit 34c76da

Please sign in to comment.