0
0
Fork 0

Add voters count support (#11917)

* Add voters count to polls

* Add ActivityPub serialization and parsing of voters count

* Add support for voters count in WebUI

* Move incrementation of voters count out of redis lock

* Reword “voters” to “people”
This commit is contained in:
ThibG 2019-09-29 22:58:01 +02:00 committed by Eugen Rochko
parent cfe2d1cc4a
commit 3babf8464b
13 changed files with 113 additions and 20 deletions

View file

@ -28,6 +28,8 @@ class ActivityPub::ProcessPollService < BaseService
end
end
voters_count = @json['votersCount']
latest_options = items.map { |item| item['name'].presence || item['content'] }
# If for some reasons the options were changed, it invalidates all previous
@ -39,7 +41,8 @@ class ActivityPub::ProcessPollService < BaseService
last_fetched_at: Time.now.utc,
expires_at: expires_at,
options: latest_options,
cached_tallies: items.map { |item| item.dig('replies', 'totalItems') || 0 }
cached_tallies: items.map { |item| item.dig('replies', 'totalItems') || 0 },
voters_count: voters_count
)
rescue ActiveRecord::StaleObjectError
poll.reload