Fix total_voter_count in polls with hidden voters.

GitOrigin-RevId: e258662b9e3f0c69210a0a32ed30ae04bc5c599f
This commit is contained in:
levlam 2019-04-26 22:44:47 +03:00
parent 8b4af163e8
commit 138bf17da9

View File

@ -440,6 +440,7 @@ td_api::object_ptr<td_api::poll> PollManager::get_poll_object(PollId poll_id, co
}
}
auto total_voter_count = poll->total_voter_count + voter_count_diff;
bool is_voted = false;
for (auto &poll_option : poll_options) {
is_voted |= poll_option->is_chosen_;
@ -449,9 +450,8 @@ td_api::object_ptr<td_api::poll> PollManager::get_poll_object(PollId poll_id, co
for (auto &poll_option : poll_options) {
poll_option->voter_count_ = 0;
}
}
auto total_voter_count = poll->total_voter_count + voter_count_diff;
} else {
// calculate vote percentage and fix total_voter_count
auto voter_counts = transform(poll_options, [](auto &poll_option) { return poll_option->voter_count_; });
auto voter_count_sum = 0;
for (auto voter_count : voter_counts) {
@ -473,6 +473,7 @@ td_api::object_ptr<td_api::poll> PollManager::get_poll_object(PollId poll_id, co
for (size_t i = 0; i < poll_options.size(); i++) {
poll_options[i]->vote_percentage_ = vote_percentage[i];
}
}
return td_api::make_object<td_api::poll>(poll_id.get(), poll->question, std::move(poll_options), total_voter_count,
poll->is_closed);
}