Function ruma_events::poll::compile_poll_results
source ยท pub fn compile_poll_results<'a>(
poll: &'a PollContentBlock,
responses: impl IntoIterator<Item = PollResponseData<'a>>,
end_timestamp: Option<MilliSecondsSinceUnixEpoch>,
) -> IndexMap<&'a str, BTreeSet<&'a UserId>>
Expand description
Generate the current results with the given poll and responses.
If the end_timestamp
is provided, any response with an origin_server_ts
after that timestamp
is ignored. If it is not provided, MilliSecondsSinceUnixEpoch::now()
will be used instead.
This method will handle invalid responses, or several response from the same user so all responses to the poll should be provided.
Returns a map of answer ID to a set of user IDs that voted for them. When using .iter()
or
.into_iter()
on the map, the results are sorted from the highest number of votes to the
lowest.