Skip to content

Commit

Permalink
Places: minor tweeking to how last activity time is computed for a Place
Browse files Browse the repository at this point in the history
    Now only updated by periodic Place activity check process.
  • Loading branch information
Misterblue committed Jun 15, 2021
1 parent 5f5a7f1 commit 1e353bf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 22 deletions.
13 changes: 2 additions & 11 deletions src/Entities/Places.ts
Expand Up @@ -78,17 +78,8 @@ export function initPlaces(): void {
aPlace.currentAttendance = domainAttendance;
updates.currentAttendance = aPlace.currentAttendance;
};
// If the Place doesn't have a last activity set it to the domain's
if (IsNullOrEmpty(aPlace.lastActivity)) {
if (IsNullOrEmpty(aDomain.timeOfLastHeartbeat)) {
// If the domain doesn't have a last update time either, assume stale Place
aPlace.lastActivity = inactivePlaceTime;
}
else {
aPlace.lastActivity = aDomain.timeOfLastHeartbeat;
};
updates.lastActivity = aPlace.lastActivity;
};
aPlace.lastActivity = aDomain.timeOfLastHeartbeat ?? inactivePlaceTime;
updates.lastActivity = aPlace.lastActivity;
}
else {
// can't find the domain to go with the place. Set everything to zero and update DB
Expand Down
4 changes: 2 additions & 2 deletions src/config.ts
Expand Up @@ -61,9 +61,9 @@ export let Config = {
'connection-request-expiration-minutes': 60 * 24 * 4, // 4 days
'friend-request-expiration-minutes': 60 * 24 * 4, // 4 days

'place-current-timeout-minutes': 30, // minutes until current place info is stale
'place-current-timeout-minutes': 5, // minutes until current place info is stale
'place-inactive-timeout-minutes': 60, // minutes until place is considered inactive
'place-check-last-activity-seconds': (5*60)-5, // seconds between checks for Place lastActivity updates
'place-check-last-activity-seconds': (3*60)-5, // seconds between checks for Place lastActivity updates

// redirection URL used for initial domain token generation,
// "METAVERSE_SERVER_URL" is replaced (from Config.metaverse.metaverse-server-url)
Expand Down
11 changes: 2 additions & 9 deletions src/route-tools/Util.ts
Expand Up @@ -291,15 +291,8 @@ export async function buildPlaceInfoSmall(pPlace: PlaceEntity, pDomain?: DomainE
'current_attendance': pPlace.currentAttendance ?? 0,
'current_images': pPlace.currentImages,
'current_info': pPlace.currentInfo,
'current_last_update_time': pPlace.currentLastUpdateTime
};
// Return the domain's last heartbeat time if the current info has not been updated
if (IsNullOrEmpty(ret.current_last_update_time)) {
const thisDomain = pDomain ?? await Domains.getDomainWithId(pPlace.domainId);
if (thisDomain) {
const domainHeartbeat = thisDomain.timeOfLastHeartbeat;
ret.current_last_update_time = domainHeartbeat ? domainHeartbeat.toISOString() : undefined;
};
'current_last_update_time': pPlace.currentLastUpdateTime,
'last_activity_update': pPlace.lastActivity
};
return ret;
};
Expand Down

0 comments on commit 1e353bf

Please sign in to comment.