mirror of
https://gitlab.com/chicken-riders/RcGcDb.git
synced 2025-02-23 00:54:09 +00:00
Fixes #26
This commit is contained in:
parent
97b2fe1880
commit
af2b779b84
|
@ -108,7 +108,7 @@ class RcQueue:
|
|||
return wiki_obj[1].rc_active is None or wiki_obj[1].rc_active > -1
|
||||
|
||||
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:
|
||||
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')
|
||||
|
@ -252,7 +252,7 @@ async def scan_group(group: str):
|
|||
DBHandler.update_db()
|
||||
continue
|
||||
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)
|
||||
new_events = 0
|
||||
for change in recent_changes:
|
||||
|
|
|
@ -34,12 +34,14 @@ class MessageQueue:
|
|||
webhooks at the same time avoiding ratelimits per Discord webhook route."""
|
||||
message_dict = defaultdict(list)
|
||||
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:
|
||||
message_dict[webhook].append(msg)
|
||||
return message_dict.items()
|
||||
message_dict[webhook].append(msg) # defaultdict{"dadibadyvbdmadgqueh23/dihjd8agdandashd": [DiscordMessage, DiscordMessage]}
|
||||
return message_dict.items() # dict_items([('daosdkosakda/adkahfwegr34', [DiscordMessage]), ('daosdkosakda/adkahfwegr33', [DiscordMessage, DiscordMessage])])
|
||||
|
||||
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:
|
||||
if self.global_rate_limit:
|
||||
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():
|
||||
# logger.debug(set_msgs)
|
||||
tasks_to_run.append(self.send_msg_set(set_msgs))
|
||||
await asyncio.gather(*tasks_to_run)
|
||||
# logger.debug(self._queue)
|
||||
await asyncio.gather(*tasks_to_run) # we wait for all send_msg_set functions to finish
|
||||
else:
|
||||
await asyncio.sleep(0.5)
|
||||
|
||||
|
|
Loading…
Reference in a new issue