Fixes and changed implementation of wiki dump functionality

This commit is contained in:
Frisk 2024-07-22 01:22:27 +02:00
parent 25bc1948cb
commit a92ea598e1
4 changed files with 8 additions and 8 deletions

View file

@ -218,7 +218,7 @@ class StackedDiscordMessage():
"length": self.length, "length": self.length,
"message_type": self.message_type, "message_type": self.message_type,
"discord_callback_message_id": self.discord_callback_message_id, "discord_callback_message_id": self.discord_callback_message_id,
"webhook": self.webhook[-3:] if self.webhook else None, "webhook": self.webhook.split("/")[0] if self.webhook else None,
"messages": [message.json() for message in self.message_list] "messages": [message.json() for message in self.message_list]
} }
return dict_obj return dict_obj

View file

@ -150,7 +150,7 @@ class Domain:
else: else:
affected = set() affected = set()
for wiki_url, wiki_obj in self.wikis.items(): for wiki_url, wiki_obj in self.wikis.items():
if all([x for x in wiki_obj.statistics.filter_by_time(60*60) if x.type in (LogType.CONNECTION_ERROR, LogType.SCAN_REASON, LogType.HTTP_ERROR)]): if all([x.type in (LogType.CONNECTION_ERROR, LogType.MEDIAWIKI_ERROR, LogType.HTTP_ERROR) for x in wiki_obj.statistics.filter_by_time(60*60)]):
affected.add(wiki_url) affected.add(wiki_url)
if affected: if affected:
return affected return affected
@ -244,7 +244,6 @@ class Domain:
discord_message["description"] = "Affected wikis: {}".format(", ".join(wikis)) + "\n" + str(ex) discord_message["description"] = "Affected wikis: {}".format(", ".join(wikis)) + "\n" + str(ex)
discord_message["description"] = discord_message["description"][0:2000] discord_message["description"] = discord_message["description"][0:2000]
# discord_message.add_field("Failure count", str(self.failures)) # discord_message.add_field("Failure count", str(self.failures))
discord_message.finish_embed_message()
header = settings["header"] header = settings["header"]
header['Content-Type'] = 'application/json' header['Content-Type'] = 'application/json'
header['X-RateLimit-Precision'] = "millisecond" header['X-RateLimit-Precision'] = "millisecond"

View file

@ -99,11 +99,12 @@ class DomainManager:
json_object["queued_messages"].append({"metadata": str(message.discord_message.metadata), "url": message.wiki.script_url}) json_object["queued_messages"].append({"metadata": str(message.discord_message.metadata), "url": message.wiki.script_url})
await connection.execute("select pg_notify('debugresponse', 'DUMP ' || $1);", json.dumps(json_object)) await connection.execute("select pg_notify('debugresponse', 'DUMP ' || $1);", json.dumps(json_object))
elif split_payload[1] == "SITE": elif split_payload[1] == "SITE":
domain = self.return_domain(self.get_domain(split_payload[2])) req_id = split_payload[2]
wiki = domain.get_wiki(split_payload[2]) domain = self.return_domain(self.get_domain(split_payload[3]))
wiki = domain.get_wiki(split_payload[3])
if wiki is not None: if wiki is not None:
await connection.execute("select pg_notify('debugresponse', 'SITE ' || $1 || ' ' || $2);", await connection.execute("select pg_notify('debugresponse', 'SITE ' || $1 || ' ' || $2);",
wiki.script_url, json.dumps(wiki.json())) req_id, json.dumps(wiki.json()))
else: else:
raise ValueError("Unknown pub/sub command! Payload: {}".format(payload)) raise ValueError("Unknown pub/sub command! Payload: {}".format(payload))

View file

@ -70,8 +70,8 @@ class Wiki:
"wiki_url": self.script_url, "wiki_url": self.script_url,
"tags": self.tags, "tags": self.tags,
"first_fetch_done": self.first_fetch_done, "first_fetch_done": self.first_fetch_done,
"rc_targets": {str(x): [webhook_url[-3:] for webhook_url in y] for x, y in self.rc_targets.items()} if self.rc_targets else None, "rc_targets": {str(x): [webhook_url.split("/")[0] for webhook_url in y] for x, y in self.rc_targets.items()} if self.rc_targets else None,
"discussion_targets": {str(x): [webhook_url[-3:] for webhook_url in y] for x, y in self.discussion_targets.items()} if self.discussion_targets else None, "discussion_targets": {str(x): [webhook_url.split("/")[0] for webhook_url in y] for x, y in self.discussion_targets.items()} if self.discussion_targets else None,
"namespaces": self.namespaces, "namespaces": self.namespaces,
"logs": self.statistics.logs, "logs": self.statistics.logs,
"last_checked_rc": self.statistics.last_checked_rc, "last_checked_rc": self.statistics.last_checked_rc,