mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-24 17:36:14 -04:00
PadMessageHandler: Use a Map
for sessioninfos
Maps are a bit more flexible, have clearer semantics, and have a convenient `size` property.
This commit is contained in:
parent
14d4aadfe4
commit
eeead46437
2 changed files with 28 additions and 37 deletions
|
@ -810,15 +810,12 @@ exports.createDiffHTML = async (padID, startRev, endRev) => {
|
|||
|
||||
exports.getStats = async () => {
|
||||
const sessionInfos = padMessageHandler.sessioninfos;
|
||||
|
||||
const sessionKeys = Object.keys(sessionInfos);
|
||||
const activePads = new Set(Object.entries(sessionInfos).map((k) => k[1].padId));
|
||||
|
||||
const map = function* (it, fn) { for (const i of it) yield fn(i); };
|
||||
const activePads = new Set(map(sessionInfos.values(), ({padId}) => padId));
|
||||
const {padIDs} = await padManager.listAllPads();
|
||||
|
||||
return {
|
||||
totalPads: padIDs.length,
|
||||
totalSessions: sessionKeys.length,
|
||||
totalSessions: sessionInfos.size,
|
||||
totalActivePads: activePads.size,
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue