Skip to content

Commit

Permalink
-- Validating Tables had some issues. Cleaned up old variable usage t…
Browse files Browse the repository at this point in the history
…o new DB layout. Also added additional messaging around validation to provide more information.

-- Added Rounding as needed on the tooltip.
  • Loading branch information
Vapok committed Jul 6, 2020
1 parent 7ce6921 commit d9bdf7b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ core.EncounterList = { -- Event IDs must be in the exact same order as core
core.CommDKPUI = {} -- global storing entire Configuration UI to hide/show UI
core.MonVersion = "v3.0.2";
core.BuildNumber = 30002;
core.ReleaseNumber = 35
core.ReleaseNumber = 36
core.defaultTable = "__default";
core.SemVer = core.MonVersion.."-r"..tostring(core.ReleaseNumber);
core.UpgradeSchema = false;
Expand Down
2 changes: 1 addition & 1 deletion Modules/Repair.lua
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ local function ConsolidateTables(keepDKP)
local search = CommDKP:Table_Search(CommDKP:GetTable(CommDKP_DKPTable, true), DKPTableTemp[i].player)

if not search then
CommDKP_Archive[DKPTableTemp[i].player] = { dkp=0, lifetime_spent=0, lifetime_gained=0, deleted=true, edited=curTime }
CommDKP:GetTable(CommDKP_Archive, true)[DKPTableTemp[i].player] = { dkp=0, lifetime_spent=0, lifetime_gained=0, deleted=true, edited=curTime }
end
end

Expand Down
32 changes: 21 additions & 11 deletions Modules/Validate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ function CommDKP:ValidateDKPTable_Loot()
local i=1
local timer = 0
local processing = false

local total = #CommDKP:GetTable(CommDKP_Loot, true);
CommDKP:Print("Building Validation Temp Table...");
local ValidateTimer = ValidateTimer or CreateFrame("StatusBar", nil, UIParent)
ValidateTimer:SetScript("OnUpdate", function(self, elapsed)
timer = timer + elapsed
if timer > 0.01 and i <= #CommDKP:GetTable(CommDKP_Loot, true) and not processing then
if timer > 0.01 and i <= total and not processing then
processing = true
local search = CommDKP:Table_Search(DKPTableTemp, CommDKP:GetTable(CommDKP_Loot, true)[i].player, "player")

Expand Down Expand Up @@ -71,11 +72,12 @@ function CommDKP:ValidateDKPTable_DKP()
local processing = false
local pause = false
local proc2 = false
local total = #CommDKP:GetTable(CommDKP_DKPHistory, true)

local ValidateTimer = ValidateTimer or CreateFrame("StatusBar", nil, UIParent)
ValidateTimer:SetScript("OnUpdate", function(self, elapsed)
timer = timer + elapsed
if timer > 0.0001 and i <= #CommDKP:GetTable(CommDKP_DKPHistory, true) and not processing and not pause then
if timer > 0.0001 and i <= total and not processing and not pause then
processing = true
pause = true

Expand Down Expand Up @@ -127,6 +129,7 @@ function CommDKP:ValidateDKPTable_DKP()
elseif i > #CommDKP:GetTable(CommDKP_DKPHistory, true) and not processing and not proc2 and not pause then
ValidateTimer:SetScript("OnUpdate", nil)
timer = 0
CommDKP:Print("Validation Temp Table built.");
CommDKP:ValidateDKPTable_Final()
end
end)
Expand All @@ -139,6 +142,8 @@ function CommDKP:ValidateDKPTable_Final()
local processing = false
local rectified = 0

CommDKP:Print("Validating Profiles...");

local ValidateTimer = ValidateTimer or CreateFrame("StatusBar", nil, UIParent)
ValidateTimer:SetScript("OnUpdate", function(self, elapsed)
timer = timer + elapsed
Expand All @@ -148,25 +153,28 @@ function CommDKP:ValidateDKPTable_Final()
local search = CommDKP:Table_Search(CommDKP:GetTable(CommDKP_DKPTable, true), DKPTableTemp[i].player, "player")

if search then
if CommDKP_Archive[DKPTableTemp[i].player] then
DKPTableTemp[i].dkp = DKPTableTemp[i].dkp + tonumber(CommDKP_Archive[DKPTableTemp[i].player].dkp)
DKPTableTemp[i].lifetime_gained = DKPTableTemp[i].lifetime_gained + tonumber(CommDKP_Archive[DKPTableTemp[i].player].lifetime_gained)
DKPTableTemp[i].lifetime_spent = DKPTableTemp[i].lifetime_spent + tonumber(CommDKP_Archive[DKPTableTemp[i].player].lifetime_spent)
if CommDKP:GetTable(CommDKP_Archive, true)[DKPTableTemp[i].player] then
DKPTableTemp[i].dkp = DKPTableTemp[i].dkp + tonumber(CommDKP:GetTable(CommDKP_Archive, true)[DKPTableTemp[i].player].dkp)
DKPTableTemp[i].lifetime_gained = DKPTableTemp[i].lifetime_gained + tonumber(CommDKP:GetTable(CommDKP_Archive, true)[DKPTableTemp[i].player].lifetime_gained)
DKPTableTemp[i].lifetime_spent = DKPTableTemp[i].lifetime_spent + tonumber(CommDKP:GetTable(CommDKP_Archive, true)[DKPTableTemp[i].player].lifetime_spent)
end
if tonumber(DKPTableTemp[i].dkp) ~= CommDKP:GetTable(CommDKP_DKPTable, true)[search[1][1]].dkp then
if CommDKP_round(tonumber(DKPTableTemp[i].dkp), core.DB.modes.rounding) ~= CommDKP_round(tonumber(CommDKP:GetTable(CommDKP_DKPTable, true)[search[1][1]].dkp), core.DB.modes.rounding) then
CommDKP:GetTable(CommDKP_DKPTable, true)[search[1][1]].dkp = tonumber(DKPTableTemp[i].dkp)
flag = true
end
if tonumber(DKPTableTemp[i].lifetime_gained) ~= CommDKP:GetTable(CommDKP_DKPTable, true)[search[1][1]].lifetime_gained then
if CommDKP_round(tonumber(DKPTableTemp[i].lifetime_gained), core.DB.modes.rounding) ~= CommDKP_round(tonumber(CommDKP:GetTable(CommDKP_DKPTable, true)[search[1][1]].lifetime_gained), core.DB.modes.rounding) then
CommDKP:GetTable(CommDKP_DKPTable, true)[search[1][1]].lifetime_gained = tonumber(DKPTableTemp[i].lifetime_gained)
flag = true
end
if tonumber(DKPTableTemp[i].lifetime_spent) ~= CommDKP:GetTable(CommDKP_DKPTable, true)[search[1][1]].lifetime_spent then
if CommDKP_round(tonumber(DKPTableTemp[i].lifetime_spent), core.DB.modes.rounding) ~= CommDKP_round(tonumber(CommDKP:GetTable(CommDKP_DKPTable, true)[search[1][1]].lifetime_spent), core.DB.modes.rounding) then
CommDKP:GetTable(CommDKP_DKPTable, true)[search[1][1]].lifetime_spent = tonumber(DKPTableTemp[i].lifetime_spent)
flag = true
end
end
if flag then rectified = rectified + 1 end
if flag then
rectified = rectified + 1
CommDKP:Print("DKP Profile for "..DKPTableTemp[i].player.." adjusted.");
end
i=i+1
processing = false
timer = 0
Expand Down Expand Up @@ -220,6 +228,7 @@ function CommDKP:ValidateDKPHistory()
timer = 0
elseif i > #CommDKP:GetTable(CommDKP_DKPHistory, true) then
ValidateTimer:SetScript("OnUpdate", nil)
CommDKP:Print("History Table Validated. "..deleted_entries.." entries deleted.");
timer = 0
CommDKP:ValidateDKPTable_Loot()
end
Expand Down Expand Up @@ -258,6 +267,7 @@ function CommDKP:ValidateLootTable() -- validation starts here
timer = 0
elseif i > #CommDKP:GetTable(CommDKP_Loot, true) then
ValidateTimer:SetScript("OnUpdate", nil)
CommDKP:Print("Loot Table Validated. "..deleted_entries.." entries deleted.");
timer = 0
CommDKP:ValidateDKPHistory()
end
Expand Down
4 changes: 2 additions & 2 deletions TableFunctions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ local function DisplayUserHistory(self, player)
end
end
GameTooltip:AddDoubleLine(" ", " ", 1.0, 1.0, 1.0);
GameTooltip:AddLine(" |cff00ff00"..L["LIFETIMEEARNED"]..": "..CommDKP:GetTable(CommDKP_DKPTable, true)[LifetimeSearch[1][1]].lifetime_gained.."|r", 1.0, 1.0, 1.0, true);
GameTooltip:AddLine(" |cffff0000"..L["LIFETIMESPENT"]..": "..CommDKP:GetTable(CommDKP_DKPTable, true)[LifetimeSearch[1][1]].lifetime_spent.."|r", 1.0, 1.0, 1.0, true);
GameTooltip:AddLine(" |cff00ff00"..L["LIFETIMEEARNED"]..": "..CommDKP_round(CommDKP:GetTable(CommDKP_DKPTable, true)[LifetimeSearch[1][1]].lifetime_gained, core.DB.modes.rounding).."|r", 1.0, 1.0, 1.0, true);
GameTooltip:AddLine(" |cffff0000"..L["LIFETIMESPENT"]..": "..CommDKP_round(CommDKP:GetTable(CommDKP_DKPTable, true)[LifetimeSearch[1][1]].lifetime_spent, core.DB.modes.rounding).."|r", 1.0, 1.0, 1.0, true);
else
GameTooltip:AddLine("No DKP Entries", 1.0, 1.0, 1.0, true);
end
Expand Down

0 comments on commit d9bdf7b

Please sign in to comment.