UNPKG

@tucmc/hazel

Version:
25 lines (24 loc) 933 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.advancedDataMappingSnippet = void 0; const lib_1 = require("../lib"); const advancedDataMappingSnippet = async (debug) => { const evalColl = new lib_1.FirestoreCollection('evaluate'); const evalData = await evalColl.readFromCache(true); if (!evalData) return; const evalMap = new lib_1.ClubRecord(evalData.getRecord()); const allCountMap = evalMap.map((k, v) => { const groupedByAction = new lib_1.DMap(v.data()).groupBy((d) => d.action); const countMap = groupedByAction.map((gk, gv) => ({ [gk]: gv?.length })); return { club: k, ...new lib_1.DMap(countMap).getRecord() }; }); debug.pauseForAnyKey('Press any key to get table result.'); debug.table(allCountMap); }; exports.advancedDataMappingSnippet = advancedDataMappingSnippet;