mirror of
https://gitlab.com/chicken-riders/RcGcDw.git
synced 2025-02-22 00:14:10 +00:00
Add additional place where cache refresh can be requested, change behavior of cache refreshes
This commit is contained in:
parent
0610a0e030
commit
2f365d44c8
|
@ -75,8 +75,8 @@ class Client:
|
|||
return self.scheduler.enter(return_delay(every or at), priority, wrap_reschedule, argument=(function, every or 86400.0, *args), kwargs=kwargs)
|
||||
|
||||
def refresh_internal_data(self):
|
||||
"""Refreshes internal storage data for wiki tags and MediaWiki messages."""
|
||||
self.__recent_changes.init_info()
|
||||
"""Requests refresh of cached internal data on next fetch."""
|
||||
self.__recent_changes.cache_refresh_requested = True
|
||||
|
||||
def create_article_path(self, article: str) -> str:
|
||||
"""Takes the string and creates an URL with it as the article name"""
|
||||
|
|
|
@ -151,6 +151,7 @@ def embed_helper(ctx: Context, message: DiscordMessage, change: dict, set_user=T
|
|||
continue # Ignore hidden tags
|
||||
else:
|
||||
tag_displayname.append(ctx.client.tags[tag])
|
||||
ctx.client.refresh_internal_data()
|
||||
else:
|
||||
tag_displayname.append(tag)
|
||||
if tag_displayname:
|
||||
|
|
|
@ -47,6 +47,7 @@ class Wiki(object):
|
|||
self.map_ips = {}
|
||||
self.downtimecredibility = 0
|
||||
self.last_downtime = 0
|
||||
self.cache_refresh_requested = False
|
||||
self.tags = {}
|
||||
self.groups = {}
|
||||
self.streak = -1
|
||||
|
@ -239,6 +240,8 @@ class Wiki(object):
|
|||
global logged_in
|
||||
rc_last_id = None
|
||||
abuselog_last_id = None
|
||||
if self.cache_refresh_requested:
|
||||
self.init_info()
|
||||
try:
|
||||
request_json = self.fetch_recentchanges_request(amount)
|
||||
except ConnectionError:
|
||||
|
@ -443,6 +446,8 @@ class Wiki(object):
|
|||
self.mw_messages[key] = re.sub(r'\[\[.*?\]\]', '', message)
|
||||
self.namespaces = startup_info["namespaces"]
|
||||
logger.info("Gathered information about the tags and interface messages.")
|
||||
self.last_cache_time = time.time()
|
||||
self.cache_refresh_requested = False # Reset flag
|
||||
else:
|
||||
logger.warning("Could not retrieve initial wiki information. Some features may not work correctly!")
|
||||
logger.debug(startup_info)
|
||||
|
|
Loading…
Reference in a new issue