Fix: strictly use active flows for online status (ignore dummy summaries)
This commit is contained in:
1 parent
f7ebd7a5c5
commit
068435ffb9
1 file changed
+3
-4
@@ -89,7 +89,7 @@ export async function fetchAgentsFromMongo(
|
||||
}
|
||||
|
||||
// 3. Optimize status check and last seen per agent using parallel indexed queries
|
||||
const twentyFourHoursAgo = new Date(Date.now() - 24 * 3600000);
|
||||
const fifteenMinutesAgoQuery = new Date(Date.now() - 15 * 60000);
|
||||
|
||||
const agentResults = await Promise.all(
|
||||
agentSource.map(async (item: any, idx: number) => {
|
||||
@@ -99,7 +99,7 @@ export async function fetchAgentsFromMongo(
|
||||
// Execute status checks for active flow, latest flow, and latest summary in parallel
|
||||
const [activeFlow, latestFlow, latestSummary] = await Promise.all([
|
||||
db.collection('flows').findOne(
|
||||
{ agent_uuid: uuid, timestamp: { $gte: twentyFourHoursAgo } },
|
||||
{ agent_uuid: uuid, timestamp: { $gte: fifteenMinutesAgoQuery } },
|
||||
{ projection: { _id: 1 } }
|
||||
),
|
||||
db.collection('flows').findOne(
|
||||
@@ -135,8 +135,7 @@ export async function fetchAgentsFromMongo(
|
||||
}
|
||||
}
|
||||
|
||||
const fifteenMinutesAgo = new Date(Date.now() - 15 * 60000);
|
||||
const isOnline = lastSeenDate ? lastSeenDate >= fifteenMinutesAgo : !!activeFlow;
|
||||
const isOnline = !!activeFlow;
|
||||
|
||||
let statusHuman = 'No Flows Detected';
|
||||
if (lastSeenDate) {
|
||||
|
||||
Reference in new issue
Block a user