Set sum types in query
This commit is contained in:
parent
4c19702390
commit
f3f8ed9e19
|
@ -43,16 +43,12 @@ def get_by_instance(instance) 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
|
||||
|
|
Loading…
Reference in New Issue