Skip to content

Commit

Permalink
Fix for surveys with too many people.
Browse files Browse the repository at this point in the history
Thanks to FallenTurtle on Discord for helping test this one.
  • Loading branch information
tmercswims committed Oct 27, 2017
1 parent 97560f6 commit 79ca938
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions survey/survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,23 @@ def _make_answer_table(self, server_id: str, survey_id: str) -> str:

def _make_waiting_list(self, server_id: str, survey_id: str) -> str:
server = self.bot.get_server(server_id)
return ", ".join(sorted(
sorted_list = sorted(
[server.get_member(m).display_name
for m in self.surveys[server_id][survey_id]["asked"]
if server.get_member(m) is not None]))
if server.get_member(m) is not None], key=lambda s: s.lower())
index = 0
string_list = ""
while len(string_list) < 1950 and index < len(sorted_list):
string_list += "{}, ".format(sorted_list[index])
index += 1

if index < len(sorted_list):
string_list += "and {} more.".format(len(sorted_list) - index)

if string_list.endswith(", "):
string_list = string_list[:-2]

return string_list

def _get_server_id_from_survey_id(self, survey_id):
for server_id, survey_ids in [
Expand Down

0 comments on commit 79ca938

Please sign in to comment.