From a4f8d9aaacd64128d88811de26853118f5ea7c46 Mon Sep 17 00:00:00 2001 From: Peter Eliasson Date: Sun, 8 Feb 2015 22:49:28 +0100 Subject: [PATCH] Started adding functionallity for purging parses. --- src/highscore.lua | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/highscore.lua b/src/highscore.lua index f52b047..a2bf04c 100644 --- a/src/highscore.lua +++ b/src/highscore.lua @@ -374,7 +374,41 @@ function highscore:PurgeParses(olderThanDate, minParsesPerPlayer) end for _, id in ipairs(oldGroupParseIds) do + local groupParse = self.db.groupParses[id]; + local guildName = groupParse.guildName; + local zoneId = groupParse.zoneId; + local difficultyId = groupParse.difficultyId; + local encounterId = groupParse.encounterId; + self.db.groupParses[id] = nil; + + local parses = getParsesTable(self.db, guildName, zoneId, difficultyId, encounterId); + + if minParsesPerPlayer == 0 then + for key, parse in pairs(parses) do + if parse.groupParseId == id then + parses[key] = nil; + end + end + else + end + + if next(parses) == nil then + self:Debug("All parses removed for", guildName, zoneId, difficultyId, encounterId); + self.db.guilds[guildName].zones[zoneId].difficulties[difficultyId].encounters[encounterId] = nil; + end + + if next(self.db.guilds[guildName].zones[zoneId].difficulties[difficultyId].encounters) == nil then + self.db.guilds[guildName].zones[zoneId].difficulties[difficultyId] = nil; + end + + if next(self.db.guilds[guildName].zones[zoneId].difficulties) == nil then + self.db.guilds[guildName].zones[zoneId] = nil; + end + + if next(self.db.guilds[guildName].zones) then + self.db.guilds[guildName] = nil; + end end end -- 1.7.9.5