This commit is contained in:
Frisk 2020-09-13 17:02:02 +02:00
parent 97b2fe1880
commit af2b779b84
No known key found for this signature in database
GPG key ID: 213F7C15068AF8AC
2 changed files with 8 additions and 7 deletions

View file

@ -108,7 +108,7 @@ class RcQueue:
return wiki_obj[1].rc_active is None or wiki_obj[1].rc_active > -1 return wiki_obj[1].rc_active is None or wiki_obj[1].rc_active > -1
async def update_queues(self): async def update_queues(self):
"""Makes a round on rcgcdw DB and looks for updates to the queues in self.domain_list""" """Makes a round on rcgcdb DB and looks for updates to the queues in self.domain_list"""
try: try:
fetch_all = db_cursor.execute( fetch_all = db_cursor.execute(
'SELECT ROWID, webhook, wiki, lang, display, wikiid, rcid FROM rcgcdw WHERE rcid != -1 OR rcid IS NULL GROUP BY wiki ORDER BY ROWID ASC') 'SELECT ROWID, webhook, wiki, lang, display, wikiid, rcid FROM rcgcdw WHERE rcid != -1 OR rcid IS NULL GROUP BY wiki ORDER BY ROWID ASC')
@ -252,7 +252,7 @@ async def scan_group(group: str):
DBHandler.update_db() DBHandler.update_db()
continue continue
categorize_events = {} categorize_events = {}
targets = generate_targets(queued_wiki.url, "AND rcid != -1 OR rcid IS NULL") targets = generate_targets(queued_wiki.url, "AND (rcid != -1 OR rcid IS NULL)")
paths = get_paths(queued_wiki.url, recent_changes_resp) paths = get_paths(queued_wiki.url, recent_changes_resp)
new_events = 0 new_events = 0
for change in recent_changes: for change in recent_changes:

View file

@ -34,12 +34,14 @@ class MessageQueue:
webhooks at the same time avoiding ratelimits per Discord webhook route.""" webhooks at the same time avoiding ratelimits per Discord webhook route."""
message_dict = defaultdict(list) message_dict = defaultdict(list)
for msg in self._queue: for msg in self._queue:
if not isinstance(msg.webhook_url, list):
raise TypeError('msg.webhook_url in _queue is not a list')
for webhook in msg.webhook_url: for webhook in msg.webhook_url:
message_dict[webhook].append(msg) message_dict[webhook].append(msg) # defaultdict{"dadibadyvbdmadgqueh23/dihjd8agdandashd": [DiscordMessage, DiscordMessage]}
return message_dict.items() return message_dict.items() # dict_items([('daosdkosakda/adkahfwegr34', [DiscordMessage]), ('daosdkosakda/adkahfwegr33', [DiscordMessage, DiscordMessage])])
async def send_msg_set(self, msg_set: tuple): async def send_msg_set(self, msg_set: tuple):
webhook_url, messages = msg_set webhook_url, messages = msg_set # str("daosdkosakda/adkahfwegr34", list(DiscordMessage, DiscordMessage, DiscordMessage)
for msg in messages: for msg in messages:
if self.global_rate_limit: if self.global_rate_limit:
return # if we are globally rate limited just wait for first gblocked request to finish return # if we are globally rate limited just wait for first gblocked request to finish
@ -74,8 +76,7 @@ class MessageQueue:
for set_msgs in await self.group_by_webhook(): for set_msgs in await self.group_by_webhook():
# logger.debug(set_msgs) # logger.debug(set_msgs)
tasks_to_run.append(self.send_msg_set(set_msgs)) tasks_to_run.append(self.send_msg_set(set_msgs))
await asyncio.gather(*tasks_to_run) await asyncio.gather(*tasks_to_run) # we wait for all send_msg_set functions to finish
# logger.debug(self._queue)
else: else:
await asyncio.sleep(0.5) await asyncio.sleep(0.5)