From 1ce99b7e762193e342a73bd1b74012dd586ec730 Mon Sep 17 00:00:00 2001 From: Linventif Date: Sun, 11 Aug 2024 23:57:03 +0000 Subject: [PATCH] add: optimisation of the requestAverage calcul --- lua/gmod_integration/shared/sh_http.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lua/gmod_integration/shared/sh_http.lua b/lua/gmod_integration/shared/sh_http.lua index feecbe3..54df517 100644 --- a/lua/gmod_integration/shared/sh_http.lua +++ b/lua/gmod_integration/shared/sh_http.lua @@ -95,13 +95,17 @@ function gmInte.http.post(endpoint, data, onSuccess, onFailed) end 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 requestAverage = requestAverage + v end requestAverage = requestAverage / 10 +end) + +function gmInte.http.postLog(endpoint, data) if requestAverage >= 2 then local logPacketIndex = #nextLogPacket + 1 table.insert(nextLogPacket, {