Added getActiveProfileIdsWithinMinutes()
to ProfileActivityService
This commit is contained in:
parent
33496aa5c3
commit
0d6239ea42
@ -25,6 +25,34 @@ export class ProfileActivityService
|
||||
return (currentTimestamp - storedActivityTimestamp) < (minutes * 60); // convert minutes to seconds to compare
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of profile ids that were active in the last x minutes
|
||||
* @param minutes How many minutes from now to search for profiles
|
||||
* @returns String array of profile ids
|
||||
*/
|
||||
public getActiveProfileIdsWithinMinutes(minutes: number): string[]
|
||||
{
|
||||
const currentTimestamp = new Date().getTime() / 1000;
|
||||
const result: string[] = [];
|
||||
|
||||
for (const id of Object.keys(this.profileActivityTimestamps ?? {}))
|
||||
{
|
||||
const lastActiveTimestamp = this.profileActivityTimestamps[id];
|
||||
if (!lastActiveTimestamp)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Profile was active in last x minutes, add to return list
|
||||
if ((currentTimestamp - lastActiveTimestamp) < (minutes * 60))
|
||||
{
|
||||
result.push(id);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the timestamp a profile was last observed active
|
||||
* @param sessionId Profile to update
|
||||
|
Loading…
Reference in New Issue
Block a user