only send data when history gets updated to reduce spam

This commit is contained in:
gretchen
2023-12-24 14:03:56 +01:00
parent 7627c395e2
commit f130238439
2 changed files with 18 additions and 18 deletions
+18
View File
@@ -1,5 +1,10 @@
module 'aux.core.history'
AuxAddon = AceLibrary("AceAddon-2.0"):new("AceComm-2.0") --im unsure this is done correctly but seems to work lol
local commPrefix = "AuxAddon";
AuxAddon:SetCommPrefix(commPrefix)
local T = require 'T'
local aux = require 'aux'
@@ -9,6 +14,11 @@ local history_schema = {'tuple', '#', {next_push='number'}, {daily_min_buyout='n
local value_cache = {}
function AuxAddon:OnEnable()
self:RegisterComm(commPrefix, "GROUP", "OnCommReceive"); --for testing purposes, not really useful in real world I think
self:RegisterComm(commPrefix, "GUILD", "OnCommReceive");
end
function aux.handle.LOAD2()
data = aux.faction_data.history
end
@@ -52,9 +62,17 @@ function M.process_auction(auction_record)
if unit_buyout_price > 0 and unit_buyout_price < (item_record.daily_min_buyout or aux.huge) then
item_record.daily_min_buyout = unit_buyout_price
write_record(auction_record.item_key, item_record)
--AuxAddon:SendCommMessage("GROUP", auction_record); --for testing purposes, not really useful in real world I think
AuxAddon:SendCommMessage("GUILD", auction_record);
--print("sent data"); for testing
end
end
function AuxAddon:OnCommReceive(prefix, sender, distribution, auction_info)
--print("received data"); for testing
M.process_auction(auction_info);
end
function M.data_points(item_key)
return read_record(item_key).data_points
end
-18
View File
@@ -1,27 +1,16 @@
module 'aux.core.scan'
AuxAddon = AceLibrary("AceAddon-2.0"):new("AceComm-2.0") --im unsure this is done correctly but seems to work lol
local commPrefix = "AuxAddon";
AuxAddon:SetCommPrefix(commPrefix)
local T = require 'T'
local aux = require 'aux'
local info = require 'aux.util.info'
local history = require 'aux.core.history'
local PAGE_SIZE = 50
function aux.handle.CLOSE()
abort()
end
function AuxAddon:OnEnable()
--self:RegisterComm(commPrefix, "GROUP", "OnCommReceive") for testing purposes, not really useful in real world I think
self:RegisterComm(commPrefix, "GUILD", "OnCommReceive");
end
do
local scan_states = {}
@@ -157,8 +146,6 @@ function scan_page(i)
auction_info.query_type = get_state().params.type
history.process_auction(auction_info)
--AuxAddon:SendCommMessage("GROUP", auction_info); for testing purposes, not really useful in real world I think
AuxAddon:SendCommMessage("GUILD", auction_info);
if (get_state().params.auto_buy_validator or pass)(auction_info) and auction_info.buyout_price >0 and auction_info.owner ~= UnitName("player") then
local send_signal, signal_received = aux.signal()
@@ -176,11 +163,6 @@ function scan_page(i)
return scan_page(i + 1)
end
function AuxAddon:OnCommReceive(prefix, sender, distribution, auction_info)
history.process_auction(auction_info)
end
function wait_for_results()
if get_state().params.type == 'bidder' then
return aux.when(function() return aux.bids_loaded() end, accept_results)