Prevent database locking by not updating latest checkin in database and instead storing it only in memory

This commit is contained in:
Jakob Friedl
2025-05-29 14:19:55 +02:00
parent d35b1d0a0d
commit 118e9eadd2
7 changed files with 40 additions and 11 deletions

View File

@@ -30,6 +30,7 @@ proc agentList*(cq: Conquest, listener: string) =
# If no argument is passed via -n, list all agents, otherwise only display agents connected to a specific listener
if listener == "":
cq.drawTable(cq.dbGetAllAgents())
else:
# Check if listener exists
if not cq.dbListenerExists(listener.toUpperAscii):
@@ -38,6 +39,7 @@ proc agentList*(cq: Conquest, listener: string) =
cq.drawTable(cq.dbGetAllAgentsByListener(listener.toUpperAscii))
# Display agent properties and details
proc agentInfo*(cq: Conquest, name: string) =
# Check if agent supplied via -n parameter exists in database
@@ -202,8 +204,8 @@ proc getTasks*(listener, agent: string): JsonNode =
# Update the last check-in date for the accessed agent
cq.agents[agent.toUpperAscii].latestCheckin = now()
if not cq.dbUpdateCheckin(agent.toUpperAscii, now().format("dd-MM-yyyy HH:mm:ss")):
return nil
# if not cq.dbUpdateCheckin(agent.toUpperAscii, now().format("dd-MM-yyyy HH:mm:ss")):
# return nil
# Return tasks in JSON format
return %cq.agents[agent.toUpperAscii].tasks.filterIt(it.status != Completed)