Skip to content

Commit

Permalink
Fixes problem of anon users being counted twice.
Browse files Browse the repository at this point in the history
Problem was that Iamus interpreted the domain-server "num_users" and
"anon_users" as two separate sets when, actually, the domain-server
heartbeats "num_users" as the total number of users and "anon_users"
is the number, of that total, that are anonymous.
Fixes #98
  • Loading branch information
Misterblue committed Aug 23, 2021
1 parent fd1ef93 commit 7e22410
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions docs/API-Domains.md
Expand Up @@ -33,7 +33,7 @@ A request returns an array of domain descriptions:
"network_address": stringNetworkAddress,
"automatic_networking": stringMode, // one of "full", "ip", or "disabled"
"restricted": boolWhetherRestricted,
"num_users": intCurrentLoggedInUsers,
"num_users": intCurrentUsers,
"anon_users": intCurrentAnonomousUsers,
"total_users": intTotalUsers,
"capacity": intMaxCapacity,
Expand All @@ -55,7 +55,7 @@ A request returns an array of domain descriptions:
"world_name": stringName
},
"users": {
"num_users": intCurrentLoggedInUsers,
"num_users": intCurrentUsers,
"anon_users": intCurrentAnonomousUsers,
"user_hostnames": [];
},
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/DomainEntity.ts
Expand Up @@ -34,7 +34,7 @@ export class DomainEntity implements Entity {
public networkPort: string; // reported network address
public networkingMode: string; // one of "full", "ip", "disabled"
public restricted: boolean; // 'true' if restricted to users with accounts
public numUsers: number; // regular users logged in
public numUsers: number; // total number of logged in users
public anonUsers: number; // number of anonymous users
public hostnames: string[]; // User segmentation

Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Places.ts
Expand Up @@ -72,7 +72,7 @@ export function initPlaces(): void {
const aDomain = await Domains.getDomainWithId(aPlace.domainId);
if (aDomain) {
// Logger.debug(` PlaceActivity: found domain for place ${aPlace.name}`);
const domainAttendance = (aDomain.numUsers ?? 0) + (aDomain.anonUsers ?? 0);
const domainAttendance = aDomain.numUsers ?? 0;
// If the Place doesn't have an attendance number or that number doesn't match the domain, update
if (IsNullOrEmpty(aPlace.currentAttendance) || aPlace.currentAttendance !== domainAttendance) {
aPlace.currentAttendance = domainAttendance;
Expand Down
2 changes: 1 addition & 1 deletion src/Monitoring/StatsMetaverse.ts
Expand Up @@ -53,7 +53,7 @@ export class StatsMetaverse extends Stat {
for await (const aDomain of Domains.enumerateAsync(new GenericFilter(
{ '$or': [ { 'numUsers': { '$gt': 0 } }, { 'anonUsers': { '$gt': 0 } } ]
}) ) ) {
totalUsers += aDomain.numUsers + aDomain.anonUsers;
totalUsers += aDomain.numUsers;
anonUsers += aDomain.anonUsers;
};
stat.Event(totalUsers);
Expand Down
4 changes: 2 additions & 2 deletions src/route-tools/Util.ts
Expand Up @@ -141,7 +141,7 @@ export async function buildDomainInfo(pDomain: DomainEntity): Promise<any> {
'active': pDomain.active ?? false,
'time_of_last_heartbeat': pDomain.timeOfLastHeartbeat?.toISOString(),
'time_of_last_heartbeat_s': pDomain.timeOfLastHeartbeat?.getTime().toString(),
'num_users': pDomain.numUsers + pDomain.anonUsers
'num_users': pDomain.numUsers
};
};

Expand All @@ -166,7 +166,7 @@ export async function buildDomainInfoV1(pDomain: DomainEntity): Promise<any> {
'restricted': pDomain.restricted,
'num_users': pDomain.numUsers,
'anon_users': pDomain.anonUsers,
'total_users': pDomain.numUsers + pDomain.anonUsers,
'total_users': pDomain.numUsers,
'capacity': pDomain.capacity,
'description': pDomain.description,
'maturity': pDomain.maturity ?? Maturity.UNRATED,
Expand Down
2 changes: 1 addition & 1 deletion src/routes/explore.ts
Expand Up @@ -61,7 +61,7 @@ const procGetExplore: RequestHandler = async (req: Request, resp: Response, next
};

// 'People' is number of people at place for old Explore script
// placeDesc.People = aDomain.numUsers + aDomain.anonUsers;
// placeDesc.People = aDomain.numUsers;
placeDesc.People = place.currentAttendance ?? 0;

placeDesc.Place = await buildPlaceInfoSmall(place, aDomain);
Expand Down

0 comments on commit 7e22410

Please sign in to comment.