Auctionator / Journalator

World of Warcraft addon. Keep track of your gold making on the AH, crafting orders and with vendors
https://www.curseforge.com/wow/addons/journalator
MIT License
10 stars 6 forks source link

Finding/exporting specific items with tertiary stats #46

Closed Zottelchen closed 1 year ago

Zottelchen commented 1 year ago

Is there a way to find all sold vendor-sold items with the tertiary stats? I would also be happy to have exported data and search through that.

plusmouse commented 1 year ago

What are you trying to find in the list?

Its possible to get a dump of all the item links and the corresponding prices for gear, Journalator doesn't store the stats directly, but the information is contained in the item links.

local timestamp = time() - 86400 -- last day
Journalator.Archiving.LoadUpTo(timestamp, function()
      local vendoredItems = CopyTable(Journalator.Archiving.GetRange(timestamp, "Vendoring"))
      -- just for example print the item link for the most recently sold item
      print(vendoredItems[1].itemLink)
end)
Zottelchen commented 1 year ago

Thank you for the snippet, that is great, I can work with that :)

Basically I am looking for items with tertiary stats (mostly speed, avoidance, sockets) which I sold earlier or on accident, so I can restore them. And I use this addon for this, since the item restoration site is ... not great. There are no filter options at all and each. single. tooltip. takes at least 20 seconds to load.😩

Zottelchen commented 1 year ago

So, this is what I ended up with:

local function setContains(set, key)
    return set[key] ~= nil
end

-- Construct your saarch pattern based on the existing global string:
local S_UPGRADE_LEVEL = "^" .. gsub(ITEM_UPGRADE_TOOLTIP_FORMAT, "%%d", "(%%d+)")

-- Create the tooltip:
local scantip         = CreateFrame("GameTooltip", "MyScanningTooltip", nil, "GameTooltipTemplate")
scantip:SetOwner(UIParent, "ANCHOR_NONE")

-- Create a function for simplicity's sake:
local function GetItemUpgradeLevel(itemLink)
    -- Pass the item link to the tooltip:
    scantip:SetHyperlink(itemLink)

    -- Scan the tooltip:
    for i = 2, scantip:NumLines() do -- Line 1 is always the name so you can skip it.
        local text = _G["MyScanningTooltipTextLeft" .. i]:GetText()
        if text and text ~= "" then
            local currentUpgradeLevel, maxUpgradeLevel = strmatch(text, S_UPGRADE_LEVEL)
            if currentUpgradeLevel then
                return "true (" .. currentUpgradeLevel .. "/" .. maxUpgradeLevel .. ")"
            end
        end
    end
    return "false"
end

print("START")
local timestamp = time() - 86400 * 90 -- last day
Journalator.Archiving.LoadUpTo(timestamp, function()
    local vendoredItems = CopyTable(Journalator.Archiving.GetRange(timestamp, "Vendoring"))
    for i, venitem in pairs(vendoredItems) do
        local _, _, venitemRarity, _, venitemMinLevel, _, _, _, venitemEquipLoc, _, _ = GetItemInfo(venitem.itemLink)
        if itemEquipLoc ~= "" and venitemMinLevel == 70 then
            local stats = GetItemStats(venitem.itemLink)
            if setContains(stats, "ITEM_MOD_CR_SPEED_SHORT") then
                print("SPEED: " .. date("%Y-%m-%d %H:%M:%S", venitem.time) .. " : " .. venitem.itemLink .. ", Upgradeable: " .. GetItemUpgradeLevel(venitem.itemLink))
            end
            if setContains(stats, "EMPTY_SOCKET_PRISMATIC") then
                print("SOCKET: " .. date("%Y-%m-%d %H:%M:%S", venitem.time) .. " : " .. venitem.itemLink .. ", Upgradeable: " .. GetItemUpgradeLevel(venitem.itemLink))
            end
            if setContains(stats, "ITEM_MOD_CR_AVOIDANCE_SHORT") then
                print("AVOIDANCE: " .. date("%Y-%m-%d %H:%M:%S", venitem.time) .. " : " .. venitem.itemLink .. ", Upgradeable: " .. GetItemUpgradeLevel(venitem.itemLink))
            end
        end
    end
end)
print("DONE")

I've used WoWLua to use this script directly ingame and it prints the items I am looking for: image

Thanks again, for your help @plusmouse 😊 I will close this now.