From 8a126181bde8f639fa9156b6ce5c274645dee783 Mon Sep 17 00:00:00 2001 From: Peter Eliasson Date: Mon, 9 Feb 2015 16:24:47 +0100 Subject: [PATCH] Removed damage/healing from roles that it doesnt matter for. No longer tracking damage done by healers, or healing done by tanks/dps. This data was not used by the UI nor anywhere else. Also moved the addon.dbVersion to only be in the main.lua file, so tracking the current version number is easier. --- src/highscore.lua | 28 ++++++++++++++++++++-------- src/main.lua | 4 ++-- src/migrate.lua | 37 ++++++++++++++++++++++++++++++++++++- src/options.lua | 1 - 4 files changed, 58 insertions(+), 12 deletions(-) diff --git a/src/highscore.lua b/src/highscore.lua index a2bf04c..638128e 100644 --- a/src/highscore.lua +++ b/src/highscore.lua @@ -39,10 +39,13 @@ addon.dbDefaults.realm.modules["highscore"] = { role = "", specName = "", itemLevel = 0, - damage = 0, - healing = 0, + (damage) = 0, + (healing) = 0, groupParseId = "" } + NOTE: + damage is included for role TANK or DAMAGER. + healing is included for role HEALER. --]] playerParses = {} } @@ -90,8 +93,6 @@ addon.dbDefaults.realm.modules["highscore"] = { } } -addon.dbVersion = addon.dbVersion + 6; - -- Constants local TRACKED_ZONE_IDS = { 994, -- Highmaul @@ -122,8 +123,11 @@ local function getReturnableParse(db, parse) parseCopy["dps"] = 0; parseCopy["hps"] = 0; if parseCopy["duration"] > 0 then - parseCopy["dps"] = parseCopy["damage"] / parseCopy["duration"]; - parseCopy["hps"] = parseCopy["healing"] / parseCopy["duration"]; + if parseCopy["role"] == "DAMAGER" or parseCopy["role"] == "TANK" then + parseCopy["dps"] = parseCopy["damage"] / parseCopy["duration"]; + elseif parseCopy["role"] == "HEALER" then + parseCopy["hps"] = parseCopy["healing"] / parseCopy["duration"]; + end end return parseCopy; @@ -184,10 +188,18 @@ local function addEncounterParseForPlayer(parsesTable, player, groupParseId) role = player.role, specName = player.specName, itemLevel = player.itemLevel, - damage = player.damage, - healing = player.healing, groupParseId = groupParseId } + + -- Only store damage for dps/tanks and only healing for healers + if player.role == "DAMAGER" or player.role == "TANK" then + parse.damage = player.damage; + elseif player.role == "HEALER" then + parse.healing = player.healing; + else + return; + end + tinsert(parsesTable, parse); end diff --git a/src/main.lua b/src/main.lua index 01b8158..16bbd69 100644 --- a/src/main.lua +++ b/src/main.lua @@ -38,9 +38,9 @@ addon.dbDefaults = { }, } --- The current db version. Clear (migrate?) the database if +-- The current db version. Migrate the database if -- version of database doesn't match this version. -addon.dbVersion = 3; +addon.dbVersion = 10; -- Constants DEBUG_PRINT = false; diff --git a/src/migrate.lua b/src/migrate.lua index b58c5ad..b712785 100644 --- a/src/migrate.lua +++ b/src/migrate.lua @@ -48,12 +48,47 @@ local function migrate8to9(db) end end end + return 9; end + +local function migrate9to10(db) + -- Removed data not used by roles. + -- * No longer storing damage done by healers. + -- * No longer storing healing done by dps/tanks. + -- * Parses must have a valid role (dps, heal, tank). + -- + -- These changes were all made to remove data that is + -- not used. + + local highscoreDb = db.realm.modules["highscore"]; + + for _, guildData in pairs(highscoreDb.guilds) do + for _, zoneData in pairs(guildData.zones) do + for _, diffData in pairs(zoneData.difficulties) do + for _, encData in pairs(diffData.encounters) do + for id, parse in pairs(encData.playerParses) do + if parse.role == "DAMAGER" or parse.role == "TANK" then + parse.healing = nil; + elseif parse.role == "HEALER" then + parse.damage = nil; + else + encData.playerParses[id] = nil; + end + end + end + end + end + end + + return 10; +end + local migrateTable = { [7] = migrate7to8, - [8] = migrate8to9 + [8] = migrate8to9, + [9] = migrate9to10 } local function resetDb() diff --git a/src/options.lua b/src/options.lua index 89b58b0..5390be3 100644 --- a/src/options.lua +++ b/src/options.lua @@ -11,7 +11,6 @@ addon.dbDefaults.realm.options = { purgeMaxParseAge = 30, purgeMinPlayerParsesPerFight = 2, } -addon.dbVersion = addon.dbVersion + 0; local optionsTable; local function createOptionsTable() -- 1.7.9.5