diff options
author | Roman Chvanikov <chvanikoff@pm.me> | 2020-05-10 09:13:24 +0300 |
---|---|---|
committer | Roman Chvanikov <chvanikoff@pm.me> | 2020-05-10 09:13:24 +0300 |
commit | f3f8ed9e19f1ab8863141ba8b31773c54f4771fb (patch) | |
tree | 397d013464a47f2ae3c15c4e5f91782590476abf /lib | |
parent | 4c197023903a183790fb2dc67b5637bfabd53bcb (diff) | |
download | pleroma-f3f8ed9e19f1ab8863141ba8b31773c54f4771fb.tar.gz |
Set sum types in query
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/counter_cache.ex | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/pleroma/counter_cache.ex b/lib/pleroma/counter_cache.ex index aa6d38687..ebd1f603d 100644 --- a/lib/pleroma/counter_cache.ex +++ b/lib/pleroma/counter_cache.ex @@ -43,16 +43,12 @@ defmodule Pleroma.CounterCache do def get_sum do CounterCache |> select([c], %{ - "public" => sum(c.public), - "unlisted" => sum(c.unlisted), - "private" => sum(c.private), - "direct" => sum(c.direct) + "public" => type(sum(c.public), :integer), + "unlisted" => type(sum(c.unlisted), :integer), + "private" => type(sum(c.private), :integer), + "direct" => type(sum(c.direct), :integer) }) |> Repo.one() - |> Enum.map(fn {visibility, dec_count} -> - {visibility, Decimal.to_integer(dec_count)} - end) - |> Enum.into(%{}) end def set(instance, values) do |