Fast fix for adding new wikis

This commit is contained in:
Frisk 2020-08-06 15:39:02 +02:00
parent 1b6be292d9
commit 129368fcbd
No known key found for this signature in database
GPG key ID: 213F7C15068AF8AC

View file

@ -105,8 +105,13 @@ class RcQueue:
full = [] full = []
for db_wiki in fetch_all.fetchall(): for db_wiki in fetch_all.fetchall():
domain = get_domain(db_wiki["wiki"]) domain = get_domain(db_wiki["wiki"])
current_domain = self[domain]
try: try:
all_wikis[db_wiki["wiki"]]
except KeyError:
all_wikis[db_wiki["wiki"]] = Wiki()
all_wikis[db_wiki["wiki"]].rc_active = True
try:
current_domain = self[domain]
if not db_wiki["ROWID"] < current_domain["last_rowid"]: if not db_wiki["ROWID"] < current_domain["last_rowid"]:
current_domain["query"].append(db_wiki) current_domain["query"].append(db_wiki)
self.to_remove.remove(db_wiki["wiki"]) self.to_remove.remove(db_wiki["wiki"])
@ -288,7 +293,10 @@ async def discussion_handler():
header["Accept"] = "application/hal+json" header["Accept"] = "application/hal+json"
async with aiohttp.ClientSession(headers=header, async with aiohttp.ClientSession(headers=header,
timeout=aiohttp.ClientTimeout(3.0)) as session: timeout=aiohttp.ClientTimeout(3.0)) as session:
local_wiki = all_wikis[db_wiki["wiki"]] # set a reference to a wiki object from memory try:
local_wiki = all_wikis[db_wiki["wiki"]] # set a reference to a wiki object from memory
except KeyError:
local_wiki = all_wikis[db_wiki["wiki"]] = Wiki()
try: try:
feeds_response = await local_wiki.fetch_feeds(db_wiki["wikiid"], session) feeds_response = await local_wiki.fetch_feeds(db_wiki["wikiid"], session)
except (WikiServerError, WikiError): except (WikiServerError, WikiError):