Skip to content

Commit

Permalink
In returned Places info, return the domain's last heartbeat time
Browse files Browse the repository at this point in the history
    for current_last_update_time if there was not a current time set.
  • Loading branch information
Misterblue committed May 31, 2021
1 parent 6d064b7 commit 881162d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/route-tools/Util.ts
Expand Up @@ -29,7 +29,7 @@ import { GenericFilter } from '@Entities/EntityFilters/GenericFilter';

import { createPublicKey } from 'crypto';
import { VKeyedCollection, VKeyValue } from '@Tools/vTypes';
import { IsNotNullOrEmpty } from '@Tools/Misc';
import { IsNotNullOrEmpty, IsNullOrEmpty } from '@Tools/Misc';
import { Logger } from '@Tools/Logging';

import { Maturity } from '@Entities/Sets/Maturity';
Expand Down Expand Up @@ -292,6 +292,14 @@ export async function buildPlaceInfoSmall(pPlace: PlaceEntity, pDomain?: DomainE
'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;
}
}
return ret;
};
// Return an array of Places names that are associated with the passed domain
Expand Down

0 comments on commit 881162d

Please sign in to comment.