From 4ef0c1c84ccdfe66641e4b1c514488cac8417ee0 Mon Sep 17 00:00:00 2001 From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Date: Tue, 9 Aug 2022 18:45:57 +0100 Subject: [PATCH] Some more stats logging (#18700) --- SQL/updates/42-43.sql | 6 ++ code/__DEFINES/misc.dm | 2 +- code/controllers/subsystem/blackbox.dm | 7 +- code/controllers/subsystem/jobs.dm | 5 +- code/modules/admin/verbs/randomverbs.dm | 2 +- code/modules/events/event_container.dm | 1 + .../hostile/mining/elites/elite.dm | 8 +- code/modules/mob/new_player/new_player.dm | 2 +- config/example/config.toml | 2 +- tools/death_rid_parser/death_rid_parser.py | 83 +++++++++++++++++++ 10 files changed, 106 insertions(+), 12 deletions(-) create mode 100644 SQL/updates/42-43.sql create mode 100644 tools/death_rid_parser/death_rid_parser.py diff --git a/SQL/updates/42-43.sql b/SQL/updates/42-43.sql new file mode 100644 index 00000000000..e99a24b0b03 --- /dev/null +++ b/SQL/updates/42-43.sql @@ -0,0 +1,6 @@ +# Updating SQL from 42-43 ~AffectedArc07 +# Adds round ID column to deaths table + +ALTER TABLE `death` ADD COLUMN `death_rid` INT NULL AFTER `tod`; + +# You may now run tools/death_rid_assigner to assign round IDs to existing deaths diff --git a/code/__DEFINES/misc.dm b/code/__DEFINES/misc.dm index 8aeb376a042..cfb019cdeee 100644 --- a/code/__DEFINES/misc.dm +++ b/code/__DEFINES/misc.dm @@ -371,7 +371,7 @@ #define INVESTIGATE_BOMB "bombs" // The SQL version required by this version of the code -#define SQL_VERSION 42 +#define SQL_VERSION 43 // Vending machine stuff #define CAT_NORMAL 1 diff --git a/code/controllers/subsystem/blackbox.dm b/code/controllers/subsystem/blackbox.dm index f83aabc5c80..fe3658b7de1 100644 --- a/code/controllers/subsystem/blackbox.dm +++ b/code/controllers/subsystem/blackbox.dm @@ -288,8 +288,8 @@ SUBSYSTEM_DEF(blackbox) lakey = L.lastattackerckey var/datum/db_query/deathquery = SSdbcore.NewQuery({" - INSERT INTO death (name, byondkey, job, special, pod, tod, laname, lakey, gender, bruteloss, fireloss, brainloss, oxyloss, coord, server_id) - VALUES (:name, :key, :job, :special, :pod, NOW(), :laname, :lakey, :gender, :bruteloss, :fireloss, :brainloss, :oxyloss, :coord, :server_id)"}, + INSERT INTO death (name, byondkey, job, special, pod, tod, laname, lakey, gender, bruteloss, fireloss, brainloss, oxyloss, coord, server_id, death_rid) + VALUES (:name, :key, :job, :special, :pod, NOW(), :laname, :lakey, :gender, :bruteloss, :fireloss, :brainloss, :oxyloss, :coord, :server_id, :rid)"}, list( "name" = L.real_name, "key" = L.key, @@ -304,7 +304,8 @@ SUBSYSTEM_DEF(blackbox) "brainloss" = L.getBrainLoss(), "oxyloss" = L.getOxyLoss(), "coord" = "[L.x], [L.y], [L.z]", - "server_id" = GLOB.configuration.system.instance_id + "server_id" = GLOB.configuration.system.instance_id, + "rid" = GLOB.round_id ) ) deathquery.warn_execute() diff --git a/code/controllers/subsystem/jobs.dm b/code/controllers/subsystem/jobs.dm index c044e80b641..5f005b67144 100644 --- a/code/controllers/subsystem/jobs.dm +++ b/code/controllers/subsystem/jobs.dm @@ -394,7 +394,7 @@ SUBSYSTEM_DEF(jobs) log_debug("Dividing Occupations took [stop_watch(watch)]s") return 1 -/datum/controller/subsystem/jobs/proc/AssignRank(mob/living/carbon/human/H, rank, joined_late = 0) +/datum/controller/subsystem/jobs/proc/AssignRank(mob/living/carbon/human/H, rank, joined_late = FALSE, log_to_db = TRUE) if(!H) return null var/datum/job/job = GetJob(rank) @@ -436,6 +436,9 @@ SUBSYSTEM_DEF(jobs) to_chat(H, "
[job.important_information]
") to_chat(H, "
----------------

") + if(log_to_db) + SSblackbox.record_feedback("nested tally", "manifest", 1, list(rank, (joined_late ? "latejoin" : "roundstart"))) + return H /datum/controller/subsystem/jobs/proc/EquipRank(mob/living/carbon/human/H, rank, joined_late = 0) // Equip and put them in an area diff --git a/code/modules/admin/verbs/randomverbs.dm b/code/modules/admin/verbs/randomverbs.dm index c58dabb6ef3..75678db3067 100644 --- a/code/modules/admin/verbs/randomverbs.dm +++ b/code/modules/admin/verbs/randomverbs.dm @@ -485,7 +485,7 @@ Traitors and the like can also be revived with the previous role mostly intact. new_character.mind.add_antag_datum(/datum/antagonist/traitor) //Add aliens. else - SSjobs.AssignRank(new_character, new_character.mind.assigned_role, 0) + SSjobs.AssignRank(new_character, new_character.mind.assigned_role, FALSE, FALSE) SSjobs.EquipRank(new_character, new_character.mind.assigned_role, 1)//Or we simply equip them. //Announces the character on all the systems, based on the record. diff --git a/code/modules/events/event_container.dm b/code/modules/events/event_container.dm index b88c7012369..da97d07533a 100644 --- a/code/modules/events/event_container.dm +++ b/code/modules/events/event_container.dm @@ -48,6 +48,7 @@ GLOBAL_LIST_EMPTY(event_last_fired) new next_event.event_type(next_event) // Events are added and removed from the processing queue in their New/kill procs log_debug("Starting event '[next_event.name]' of severity [GLOB.severity_to_string[severity]].") + SSblackbox.record_feedback("nested tally", "events", 1, list(GLOB.severity_to_string[severity], next_event.name)) next_event = null // When set to null, a random event will be selected next time else // If not, wait for one minute, instead of one tick, before checking again. diff --git a/code/modules/mob/living/simple_animal/hostile/mining/elites/elite.dm b/code/modules/mob/living/simple_animal/hostile/mining/elites/elite.dm index e43e6b4cd3b..5c2ed1949c5 100644 --- a/code/modules/mob/living/simple_animal/hostile/mining/elites/elite.dm +++ b/code/modules/mob/living/simple_animal/hostile/mining/elites/elite.dm @@ -349,9 +349,9 @@ While using this makes the system rely on OnFire, it still gives options for tim new mychild.loot_drop(lootbox) else new /obj/item/tumor_shard(lootbox) - SSblackbox.record_feedback("tally", "Player controlled Elite loss", 1, mychild.name) + SSblackbox.record_feedback("tally", "player_controlled_elite_loss", 1, mychild.name) else - SSblackbox.record_feedback("tally", "AI controlled Elite loss", 1, mychild.name) + SSblackbox.record_feedback("tally", "ai_controlled_elite_loss", 1, mychild.name) qdel(src) /obj/structure/elite_tumor/proc/onEliteWon() @@ -360,7 +360,7 @@ While using this makes the system rely on OnFire, it still gives options for tim clear_activator(activator) mychild.revive() if(boosted) - SSblackbox.record_feedback("tally", "Player controlled Elite win", 1, mychild.name) + SSblackbox.record_feedback("tally", "player_controlled_elite_win", 1, mychild.name) times_won++ mychild.maxHealth = mychild.maxHealth * 0.4 mychild.health = mychild.maxHealth @@ -372,7 +372,7 @@ While using this makes the system rely on OnFire, it still gives options for tim M.playsound_local(T, null, 100, FALSE, 0, FALSE, pressure_affected = FALSE, S = elite_sound) M.flash_screen_color("#FF0000", 2.5 SECONDS) else - SSblackbox.record_feedback("tally", "AI controlled Elite win", 1, mychild.name) + SSblackbox.record_feedback("tally", "ai_controlled_elite_win", 1, mychild.name) if(times_won == 1) mychild.playsound_local(get_turf(mychild), 'sound/magic/cult_spell.ogg', 40, 0) to_chat(mychild, "= %s ORDER BY tod ASC", [first_logged_round]) +all_deaths = cursor.fetchall() +print("Found {} deaths to assign round IDs to".format(len(all_deaths))) + +replacement_map = {} +round_idx = 0 +current_round = round_times_map[round_idx] + + +print("Beginning iteration") +for death in all_deaths: + # If the death time is after the current round + while death[1] > current_round["etime"]: + round_idx += 1 + current_round = round_times_map[round_idx] + + if (death[1] >= current_round["stime"]) and (death[1] <= current_round["etime"]): + replacement_map[str(death[0])] = current_round["rid"] + else: + # I tested this on prod data, it never happened + print("WHAT?!") + print(death) + print(current_round) + +print("Updating the existing death rows") + +for death_id in replacement_map: + cursor.execute("UPDATE death SET death_rid=%s WHERE id=%s", [replacement_map[death_id], death_id]) + +cursor.close() +print("Saving...") +db.commit() +print("Done!")