Simplify stats sending.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 6m16s

This commit is contained in:
Cory McWilliams 2024-07-24 12:15:05 -04:00
parent 24cec21465
commit 221f276c4b
3 changed files with 5 additions and 21 deletions

View File

@ -211,10 +211,6 @@ async function socket(request, response, client) {
if (process && process.timeout > 0) {
setTimeout(ping, process.timeout);
}
} else if (message.action == 'enableStats') {
if (process) {
core.enableStats(process, message.enabled);
}
} else if (message.action == 'resetPermission') {
if (process) {
process.resetPermission(message.permission);

View File

@ -1274,7 +1274,6 @@ function _receive_websocket_message(message) {
document.getElementById('viewPane').style.display = message.edit_only
? 'none'
: 'flex';
send({action: 'enableStats', enabled: true});
} else if (message && message.action == 'ping') {
send({action: 'pong'});
} else if (message && message.action == 'stats') {

View File

@ -286,7 +286,6 @@ async function getProcessBlob(blobId, key, options) {
process.lastActive = Date.now();
process.lastPing = null;
process.timeout = options.timeout;
process.stats = false;
process.ready = new Promise(function (resolve, reject) {
resolveReady = resolve;
rejectReady = reject;
@ -778,6 +777,10 @@ async function getProcessBlob(blobId, key, options) {
}
await process.task.execute({name: appSourceName, source: appSource});
resolveReady(process);
if (!gStatsTimer) {
gStatsTimer = true;
sendStats();
}
} catch (error) {
if (process.app) {
if (process?.task?.onError) {
@ -1200,7 +1203,7 @@ async function loadSettings() {
*/
function sendStats() {
let apps = Object.values(gProcesses)
.filter((process) => process.app && process.stats)
.filter((process) => process.app)
.map((process) => process.app);
if (apps.length) {
let stats = getStats();
@ -1213,19 +1216,6 @@ function sendStats() {
}
}
/**
* TODOC
* @param {*} process
* @param {*} enabled
*/
function enableStats(process, enabled) {
process.stats = enabled;
if (!gStatsTimer) {
gStatsTimer = true;
sendStats();
}
}
/**
* TODOC
*/
@ -1342,7 +1332,6 @@ function storePermission(user, packageOwner, packageName, permission, allow) {
export {
gGlobalSettings as globalSettings,
setGlobalSettings,
enableStats,
invoke,
getSessionProcessBlob,
};