mirror of
https://gitlab.com/chicken-riders/RcGcDw.git
synced 2025-02-23 00:24:09 +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)
|
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):
|
def refresh_internal_data(self):
|
||||||
"""Refreshes internal storage data for wiki tags and MediaWiki messages."""
|
"""Requests refresh of cached internal data on next fetch."""
|
||||||
self.__recent_changes.init_info()
|
self.__recent_changes.cache_refresh_requested = True
|
||||||
|
|
||||||
def create_article_path(self, article: str) -> str:
|
def create_article_path(self, article: str) -> str:
|
||||||
"""Takes the string and creates an URL with it as the article name"""
|
"""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
|
continue # Ignore hidden tags
|
||||||
else:
|
else:
|
||||||
tag_displayname.append(ctx.client.tags[tag])
|
tag_displayname.append(ctx.client.tags[tag])
|
||||||
|
ctx.client.refresh_internal_data()
|
||||||
else:
|
else:
|
||||||
tag_displayname.append(tag)
|
tag_displayname.append(tag)
|
||||||
if tag_displayname:
|
if tag_displayname:
|
||||||
|
|
|
@ -47,6 +47,7 @@ class Wiki(object):
|
||||||
self.map_ips = {}
|
self.map_ips = {}
|
||||||
self.downtimecredibility = 0
|
self.downtimecredibility = 0
|
||||||
self.last_downtime = 0
|
self.last_downtime = 0
|
||||||
|
self.cache_refresh_requested = False
|
||||||
self.tags = {}
|
self.tags = {}
|
||||||
self.groups = {}
|
self.groups = {}
|
||||||
self.streak = -1
|
self.streak = -1
|
||||||
|
@ -239,6 +240,8 @@ class Wiki(object):
|
||||||
global logged_in
|
global logged_in
|
||||||
rc_last_id = None
|
rc_last_id = None
|
||||||
abuselog_last_id = None
|
abuselog_last_id = None
|
||||||
|
if self.cache_refresh_requested:
|
||||||
|
self.init_info()
|
||||||
try:
|
try:
|
||||||
request_json = self.fetch_recentchanges_request(amount)
|
request_json = self.fetch_recentchanges_request(amount)
|
||||||
except ConnectionError:
|
except ConnectionError:
|
||||||
|
@ -443,6 +446,8 @@ class Wiki(object):
|
||||||
self.mw_messages[key] = re.sub(r'\[\[.*?\]\]', '', message)
|
self.mw_messages[key] = re.sub(r'\[\[.*?\]\]', '', message)
|
||||||
self.namespaces = startup_info["namespaces"]
|
self.namespaces = startup_info["namespaces"]
|
||||||
logger.info("Gathered information about the tags and interface messages.")
|
logger.info("Gathered information about the tags and interface messages.")
|
||||||
|
self.last_cache_time = time.time()
|
||||||
|
self.cache_refresh_requested = False # Reset flag
|
||||||
else:
|
else:
|
||||||
logger.warning("Could not retrieve initial wiki information. Some features may not work correctly!")
|
logger.warning("Could not retrieve initial wiki information. Some features may not work correctly!")
|
||||||
logger.debug(startup_info)
|
logger.debug(startup_info)
|
||||||
|
|
Loading…
Reference in a new issue