add: optimisation of the requestAverage calcul

This commit is contained in:
Linventif 2024-08-11 23:57:03 +00:00
parent 42a216dfb6
commit 1ce99b7e76

View File

@ -95,13 +95,17 @@ function gmInte.http.post(endpoint, data, onSuccess, onFailed)
end end
local nextLogPacket = {} local nextLogPacket = {}
function gmInte.http.postLog(endpoint, data) local requestAverage = 0
local requestAverage = 0 timer.Create("gmInte:http:requestAverage", 1, 0, function()
requestAverage = 0
for k, v in ipairs(requestIndicator) do for k, v in ipairs(requestIndicator) do
requestAverage = requestAverage + v requestAverage = requestAverage + v
end end
requestAverage = requestAverage / 10 requestAverage = requestAverage / 10
end)
function gmInte.http.postLog(endpoint, data)
if requestAverage >= 2 then if requestAverage >= 2 then
local logPacketIndex = #nextLogPacket + 1 local logPacketIndex = #nextLogPacket + 1
table.insert(nextLogPacket, { table.insert(nextLogPacket, {