mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-15 18:14:22 +01:00
[MIRROR] Adminwho now caches feedback links until admins are reloaded (and also works again) [MDB IGNORE] (#14135)
* Adminwho now caches feedback links until admins are reloaded (and also works again) (#67307) * Adminwho now caches feedback links until admins are reloaded * Restore dbconfig * Fix feedback links, make them query only if necessary, and not on load admins * Wait longer before checking DB connection * Back on my dbconfig shit fixes (Adminwho is slower than it needs to be after feedback links) #67150. also fixes (timber breaking feedback links totally by qdeling the datum too early) #67360. * Adminwho now caches feedback links until admins are reloaded (and also works again) Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
This commit is contained in:
@@ -258,7 +258,7 @@ GLOBAL_PROTECT(protected_ranks)
|
||||
new /datum/admins(ranks_from_rank_name(admin_rank), ckey(admin_key), force_active = FALSE, protected = TRUE)
|
||||
|
||||
if(!CONFIG_GET(flag/admin_legacy_system) || dbfail)
|
||||
var/datum/db_query/query_load_admins = SSdbcore.NewQuery("SELECT ckey, `rank` FROM [format_table_name("admin")] ORDER BY `rank`")
|
||||
var/datum/db_query/query_load_admins = SSdbcore.NewQuery("SELECT ckey, `rank`, feedback FROM [format_table_name("admin")] ORDER BY `rank`")
|
||||
if(!query_load_admins.Execute())
|
||||
message_admins("Error loading admins from database. Loading from backup.")
|
||||
log_sql("Error loading admins from database. Loading from backup.")
|
||||
@@ -267,6 +267,7 @@ GLOBAL_PROTECT(protected_ranks)
|
||||
while(query_load_admins.NextRow())
|
||||
var/admin_ckey = ckey(query_load_admins.item[1])
|
||||
var/admin_rank = query_load_admins.item[2]
|
||||
var/admin_feedback = query_load_admins.item[3]
|
||||
var/skip
|
||||
|
||||
var/list/admin_ranks = ranks_from_rank_name(admin_rank)
|
||||
@@ -277,7 +278,8 @@ GLOBAL_PROTECT(protected_ranks)
|
||||
if(GLOB.admin_datums[admin_ckey] || GLOB.deadmins[admin_ckey])
|
||||
skip = 1
|
||||
if(!skip)
|
||||
new /datum/admins(admin_ranks, admin_ckey)
|
||||
var/datum/admins/admin_holder = new(admin_ranks, admin_ckey)
|
||||
admin_holder.cached_feedback_link = admin_feedback || NO_FEEDBACK_LINK
|
||||
qdel(query_load_admins)
|
||||
//load admins from backup file
|
||||
if(dbfail)
|
||||
|
||||
@@ -30,9 +30,7 @@ GLOBAL_PROTECT(href_token)
|
||||
var/href_token
|
||||
|
||||
/// Link from the database pointing to the admin's feedback forum
|
||||
var/cached_forum_link
|
||||
/// Last access time in deciseconds (playing nice with the MSO 10 second rule)
|
||||
var/last_forum_access_time
|
||||
var/cached_feedback_link
|
||||
|
||||
var/deadmined
|
||||
|
||||
@@ -172,25 +170,32 @@ GLOBAL_PROTECT(href_token)
|
||||
|
||||
/// Returns the feedback forum thread for the admin holder's owner, as according to DB.
|
||||
/datum/admins/proc/feedback_link()
|
||||
if(world.time - last_forum_access_time <= 10 SECONDS)
|
||||
return cached_forum_link
|
||||
// This intentionally does not follow the 10-second maximum TTL rule,
|
||||
// as this can be reloaded through the Reload-Admins verb.
|
||||
if (cached_feedback_link == NO_FEEDBACK_LINK)
|
||||
return null
|
||||
|
||||
last_forum_access_time = world.time
|
||||
if (!isnull(cached_feedback_link))
|
||||
return cached_feedback_link
|
||||
|
||||
if (!SSdbcore.IsConnected())
|
||||
return FALSE
|
||||
|
||||
var/datum/db_query/feedback_query = SSdbcore.NewQuery("SELECT feedback FROM [format_table_name("admin")] WHERE ckey = '[owner.ckey]'")
|
||||
|
||||
if(!feedback_query.Execute())
|
||||
log_sql("Error retrieving feedback link for [src]")
|
||||
qdel(feedback_query)
|
||||
return cached_forum_link
|
||||
return FALSE
|
||||
|
||||
if(!feedback_query.NextRow())
|
||||
qdel(feedback_query)
|
||||
return FALSE // no feedback link exists
|
||||
|
||||
cached_feedback_link = feedback_query.item[1] || NO_FEEDBACK_LINK
|
||||
qdel(feedback_query)
|
||||
|
||||
cached_forum_link = feedback_query.item[1]
|
||||
return cached_forum_link
|
||||
return cached_feedback_link
|
||||
|
||||
/datum/admins/proc/check_for_rights(rights_required)
|
||||
if(rights_required && !(rights_required & rank_flags()))
|
||||
|
||||
Reference in New Issue
Block a user