ItemDB Optimization and Search Fix

This commit is contained in:
Rvng
2021-09-20 18:51:44 -04:00
parent 81ae84fae8
commit 715cbda69c
3 changed files with 11245 additions and 11215 deletions
+11 -4
View File
@@ -148,8 +148,8 @@ AtlasLoot_Difficulty = {
MythicPlus = {5, 6, 7, 8, 9, 10, 11, 12, 13, 14};
--Helper Enums to Set min and max difficulties
MIN_DIF = 8;
MAX_DIF = 9;
MIN_DIF = 18;
MAX_DIF = 19;
}
--AtlasLoot_Difficulty was too long to write for enum reasons
AL_Dif = AtlasLoot_Difficulty;
@@ -884,11 +884,17 @@ function AtlasLoot_ShowItemsFrame(dataID, dataSource, boss, pFrame)
--Check if difficulties exist, if so show difficulty select buttons
if (AtlasLoot_Data[dataID].Dif ~= nil) then
if (dataID ~= "SearchResult" and AtlasLoot_Data[dataID].Dif ~= nil) then
AtlasLootMythicButton.difficulty_type = AtlasLoot_Data[dataID].Type or "Dungeon"
AtlasLootMythicButton:Show();
AtlasLoot_DifficultySelect:Show();
end
if (dataID == "SearchResult" and dataSource[dataID].Dif ~= nil) then
AtlasLootMythicButton.difficulty_type = dataSource[dataID].Type or "Dungeon"
AtlasLootMythicButton:Show();
AtlasLoot_DifficultySelect:Show();
end
-- Show the Filter Check-Box
if dataID ~= "WishList" and dataID ~= "SearchResult" and dataSource_backup ~= "AtlasLootCrafting" then
@@ -1621,6 +1627,7 @@ function QueryItems(instance, difficulty, expansion)
for b = 1, #AtlasLoot_DewDropDown_SubTables[inst] do
local boss = AtlasLoot_DewDropDown_SubTables[inst][b][2];
if(AtlasLoot_Data[boss] ~= nil and AtlasLoot_Data[boss].Type ~= nil and AtlasLoot_Data[boss].Type == instance) then
print("Query for "..boss.." in instance "..inst.." started");
local n = 1;
local querytime = 0;
local now = 0;
@@ -1642,6 +1649,7 @@ function QueryItems(instance, difficulty, expansion)
end
elseif AtlasLoot_DewDropDown[_men][ex_sel[expansion]][i][1][3] == "Table" then
if(AtlasLoot_Data[inst] ~= nil and AtlasLoot_Data[inst].Type ~= nil and AtlasLoot_Data[inst].Type == instance) then
print("Query for "..inst.." in instance "..inst.." started");
local n = 1;
local querytime = 0;
local now = 0;
@@ -1662,5 +1670,4 @@ function QueryItems(instance, difficulty, expansion)
end
end
end
print("You may need to reload your UI to finalize the Query")
end
+11141 -11133
View File
File diff suppressed because it is too large Load Diff
+93 -78
View File
@@ -453,95 +453,106 @@ function AtlasLoot:Search(Text)
local operator = HaveOperator(text);
for dataID, data in pairs(AtlasLoot_Data) do
for _, v in ipairs(data) do
if type(v[2]) == "number" and v[2] > 0 then
-- Name, Link, Quality(num), iLvl(num), minLvl(num), itemType(localized string), itemSubType(localized string), stackCount(num), itemEquipLoc(enum), texture(link to a local file), displayId(num)
local itemName, _, itemQuality, itemLvl, minLvl, _, _, _, itemEquipLoc = GetItemInfo(v[2]);
if not itemName then itemName = gsub(v[4], "=q%d=", "") end
local queryDifficulties = 1;
local maxDifficulties = 1;
if operator ~= nil then
local stats = GetItemStats("item:"..tostring(v[2]));
if data.Type ~= nil then
queryDifficulties = 0;
maxDifficulties = 4;
end
for dif = 1, maxDifficulties do
for _, v in ipairs(data) do
local _id = AL_FindId(gsub(v[4], "=q%d=", ""), dif + queryDifficulties) or v[2]
if type(_id) == "number" and _id > 0 then
-- Name, Link, Quality(num), iLvl(num), minLvl(num), itemType(localized string), itemSubType(localized string), stackCount(num), itemEquipLoc(enum), texture(link to a local file), displayId(num)
local itemName, _, itemQuality, itemLvl, minLvl, _, _, _, itemEquipLoc = GetItemInfo(_id);
-- Currently only supports "&"
local binaryOperator = HaveBinaryOperator(text);
if binaryOperator ~= nil then
local searchConditionsMet = true;
local searchItems = SplitString(text, binaryOperator);
if not itemName then itemName = gsub(v[4], "=q%d=", "") end
if operator ~= nil then
local stats = GetItemStats("item:"..tostring(_id));
if searchItems then
for _, searchTextItem in ipairs(searchItems) do
local localOperator = HaveOperator(searchTextItem);
if not localOperator
or not (
-- Stat Filter
IsItemStatMatch(searchTextItem, stats, localOperator)
-- Item Level Filter
or IsItemLevelFilterMatch(searchTextItem, itemLvl, itemEquipLoc, localOperator)
)
then
searchConditionsMet = false;
break;
-- Currently only supports "&"
local binaryOperator = HaveBinaryOperator(text);
if binaryOperator ~= nil then
local searchConditionsMet = true;
local searchItems = SplitString(text, binaryOperator);
if searchItems then
for _, searchTextItem in ipairs(searchItems) do
local localOperator = HaveOperator(searchTextItem);
if not localOperator
or not (
-- Stat Filter
IsItemStatMatch(searchTextItem, stats, localOperator)
-- Item Level Filter
or IsItemLevelFilterMatch(searchTextItem, itemLvl, itemEquipLoc, localOperator)
)
then
searchConditionsMet = false;
break;
end
end
if searchConditionsMet then
AddItemToSearchResult(_id, v[3], itemName, lootpage, dataID);
end
end
if searchConditionsMet then
AddItemToSearchResult(v[2], v[3], itemName, lootpage, dataID);
else
-- Stat Filter
if IsItemStatMatch(text, stats, operator)
-- Item Level Filter
or IsItemLevelFilterMatch(text, itemLvl, itemEquipLoc, operator)
then
AddItemToSearchResult(_id, v[3], itemName, lootpage, dataID);
end
-- TODO itemQuality
-- TODO minLvl
-- TODO itemEquipLoc
end
else
-- Stat Filter
if IsItemStatMatch(text, stats, operator)
-- Item Level Filter
or IsItemLevelFilterMatch(text, itemLvl, itemEquipLoc, operator)
then
AddItemToSearchResult(v[2], v[3], itemName, lootpage, dataID);
-- Stat Table Cleanup
if stats then
table.wipe(stats);
end
-- TODO itemQuality
-- TODO minLvl
-- TODO itemEquipLoc
end
-- Stat Table Cleanup
if stats then
table.wipe(stats);
local found;
if partial then
found = string.find(string.lower(itemName), text);
else
found = string.lower(itemName) == text;
end
end
local found;
if partial then
found = string.find(string.lower(itemName), text);
else
found = string.lower(itemName) == text;
end
if found then
local _, _, quality = string.find(v[4], "=q(%d)=");
if quality then itemName = "=q"..quality.."="..itemName end
if AtlasLoot_TableNames[dataID] then lootpage = AtlasLoot_TableNames[dataID][1]; else lootpage = "Argh!"; end
table.insert(AtlasLootCharDB["SearchResult"], { 0, v[2], v[3], itemName, lootpage, "", "", dataID.."|".."\"\"" });
end
elseif (v[2] ~= nil) and (v[2] ~= "") and (string.sub(v[2], 1, 1) == "s") then
local spellName = GetSpellInfo(string.sub(v[2], 2));
if not spellName then
if (string.sub(v[4], 1, 2) == "=d") then
spellName = gsub(v[4], "=ds=", "");
else
spellName = gsub(v[4], "=q%d=", "");
end
end
local found;
if partial then
found = string.find(string.lower(spellName), text);
else
found = string.lower(spellName) == text;
end
if found then
spellName = string.sub(v[4], 1, 4)..spellName;
if AtlasLoot_TableNames[dataID][1] then lootpage = AtlasLoot_TableNames[dataID][1]; else lootpage = "Argh!"; end
table.insert(AtlasLootCharDB["SearchResult"], { 0, v[2], v[3], spellName, lootpage, "", "", dataID.."|".."\"\"" });
end
end
end
if found then
local _, _, quality = string.find(v[4], "=q(%d)=");
if quality then itemName = "=q"..quality.."="..itemName end
if AtlasLoot_TableNames[dataID] then lootpage = AtlasLoot_TableNames[dataID][1]; else lootpage = "Argh!"; end
table.insert(AtlasLootCharDB["SearchResult"], { 0, _id, v[3], itemName, lootpage, "", "", dataID.."|".."\"\"" });
end
elseif (v[2] ~= nil) and (v[2] ~= "") and (string.sub(v[2], 1, 1) == "s") then
local spellName = GetSpellInfo(string.sub(v[2], 2));
if not spellName then
if (string.sub(v[4], 1, 2) == "=d") then
spellName = gsub(v[4], "=ds=", "");
else
spellName = gsub(v[4], "=q%d=", "");
end
end
local found;
if partial then
found = string.find(string.lower(spellName), text);
else
found = string.lower(spellName) == text;
end
if found then
spellName = string.sub(v[4], 1, 4)..spellName;
if AtlasLoot_TableNames[dataID][1] then lootpage = AtlasLoot_TableNames[dataID][1]; else lootpage = "Argh!"; end
table.insert(AtlasLootCharDB["SearchResult"], { 0, v[2], v[3], spellName, lootpage, "", "", dataID.."|".."\"\"" });
end
end
end
end
end
if #AtlasLootCharDB["SearchResult"] == 0 then
@@ -650,5 +661,9 @@ function AtlasLoot:GetSearchResultPage(page)
table.insert(result, SearchResult[i]);
k=k+1;
end
result.Type = "Dungeon";
result.Dif = GetDifficultyTier();
return result, pageMax;
end