Bonfire.Poll.Votes (Bonfire v1.0.1-social-alpha.28)
View SourceSummary
Functions
Returns the average base score (rounded) for a choice.
Returns votes count or weighted total for a choice, only if poll voting is closed or owned by current user.
Sums the weights of all votes for a choice.
Callback implementation for Bonfire.Federate.ActivityPub.FederationModules.federation_module/0.
Callback implementation for Bonfire.Common.ContextModule.query_module/0.
Returns true a choice only if poll voting is closed or owned by current user
Callback implementation for Bonfire.Common.ContextModule.schema_module/0.
Functions
Returns the average base score (rounded) for a choice.
Examples
iex> Bonfire.Poll.Votes.calculate_average_base_score(3, 2)
2
iex> Bonfire.Poll.Votes.calculate_average_base_score(nil, 2)
nil
iex> Bonfire.Poll.Votes.calculate_average_base_score(0, 0)
0
Returns votes count or weighted total for a choice, only if poll voting is closed or owned by current user.
For weighted_multiple polls, returns the sum of weights for all votes on the choice. For other formats, returns the count of votes. Returns nil if results are not visible.
Sums the weights of all votes for a choice.
Examples
iex> Bonfire.Poll.Votes.calculate_total([%{vote_weight: 2}, %{vote_weight: 1}], 1)
3
iex> Bonfire.Poll.Votes.calculate_total([%{vote_weight: -1}, %{vote_weight: 2}], 2)
3
Callback implementation for Bonfire.Federate.ActivityPub.FederationModules.federation_module/0.
Callback implementation for Bonfire.Common.ContextModule.query_module/0.
Returns true a choice only if poll voting is closed or owned by current user
Callback implementation for Bonfire.Common.ContextModule.schema_module/0.