|
279 | 279 | } } |
280 | 280 | end |
281 | 281 |
|
| 282 | +-- db maintenance |
| 283 | +do |
| 284 | + local function IsZoneEnabled(zoneID) -- check if the zone belongs to any enabled module. |
| 285 | + for module in pairs(RDO.db.profile.enabledModules) do |
| 286 | + local zones = RDO.RDDB[module] |
| 287 | + if zones and zones[zoneID] then |
| 288 | + return true |
| 289 | + end |
| 290 | + end |
| 291 | + return RDO.RDDB['[Custom Debuffs]'][zoneID] ~= nil |
| 292 | + end |
| 293 | + |
| 294 | + local function RemoveDisabledZones() |
| 295 | + local delete, zcount, dcount = {}, 0, 0 |
| 296 | + for _,status in ipairs(RDO.statuses) do |
| 297 | + local debuffs = status.dbx.debuffs |
| 298 | + for zone in pairs(debuffs) do |
| 299 | + if not IsZoneEnabled(zone) then |
| 300 | + delete[zone] = debuffs |
| 301 | + zcount = zcount + 1 |
| 302 | + dcount = dcount + #debuffs[zone] |
| 303 | + end |
| 304 | + end |
| 305 | + end |
| 306 | + if zcount>0 or dcount>0 then |
| 307 | + Grid2Options:ConfirmDialog(string.format(L["Raid Debuffs Warning:\n %d zones and %d orphan raid debuffs has been detectetd. Do you want to remove this information ?"], zcount, dcount), function() |
| 308 | + for zone, debuffs in pairs(delete) do |
| 309 | + debuffs[zone] = nil |
| 310 | + end |
| 311 | + RDO:UpdateZoneSpells() |
| 312 | + RDO:RefreshAdvancedOptions() |
| 313 | + print("Grid2RaidDebuffs database maintenance finished.") |
| 314 | + end) |
| 315 | + else |
| 316 | + Grid2Options:MessageDialog(L["Raid debuffs database is OK, nothing to clean."]) |
| 317 | + end |
| 318 | + end |
| 319 | + |
| 320 | + options.maintenance = { type = "group", order = 20, name = L["Maintenance"], inline= true, args = { |
| 321 | + clean = { |
| 322 | + type = "execute", |
| 323 | + order = 10, |
| 324 | + name = L["Clean Database"], |
| 325 | + desc = L["Clean the database removing orphan raid debuffs."], |
| 326 | + func = function(info) |
| 327 | + RemoveDisabledZones() |
| 328 | + end, |
| 329 | + } |
| 330 | + } } |
| 331 | +end |
| 332 | + |
282 | 333 | ---------------------------------------------------------------------- |
283 | 334 | -- |
284 | 335 | ---------------------------------------------------------------------- |
|
0 commit comments