diff options
author | rinpatch <rinpatch@sdf.org> | 2019-05-21 14:27:09 +0300 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2019-05-21 14:27:09 +0300 |
commit | f28747858bf3265e8b82eb587919f5a89386bed7 (patch) | |
tree | 0ec6d3fcbe05cd32e3230ff4365929400b30e421 /lib | |
parent | a53d06273080525fdda332291838b0c95ed69690 (diff) | |
download | pleroma-f28747858bf3265e8b82eb587919f5a89386bed7.tar.gz |
Actual vote count in poll view
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/mastodon_api/views/status_view.ex | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index 0df8bb5c2..c501c213c 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -338,8 +338,6 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do (object.data["closed"] || object.data["endTime"]) |> NaiveDateTime.from_iso8601!() - votes_count = object.data["votes_count"] || 0 - expired = end_time |> NaiveDateTime.compare(NaiveDateTime.utc_now()) @@ -348,12 +346,14 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do _ -> false end - options = - Enum.map(options, fn %{"name" => name} = option -> - %{ - title: HTML.strip_tags(name), - votes_count: option["replies"]["votes_count"] || 0 - } + {options, votes_count} = + Enum.map_reduce(options, 0, fn %{"name" => name} = option, count -> + current_count = option["replies"]["totalItems"] || 0 + + {%{ + title: HTML.strip_tags(name), + votes_count: current_count + }, current_count + count} end) %{ |