2026-04-24 FE Backup
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
def groupJournalByPathAndState(events):
|
||||
"""
|
||||
Creates a summary list of dicts with displayPath, eventState, and occurrence count.
|
||||
|
||||
Returns list sorted by displayPath (alphabetical), then by eventState.
|
||||
"""
|
||||
if not events:
|
||||
return []
|
||||
|
||||
groups = {} # outer: source → {eventState: count}
|
||||
|
||||
for event in events:
|
||||
|
||||
es = event.get('eventState')
|
||||
source = event.get('source')
|
||||
|
||||
# Get or create inner dict
|
||||
inner = groups.setdefault(source, {})
|
||||
# Increment count (inner.setdefault would also work, but +1 is clearer)
|
||||
inner[es] = inner.get(es, 0) + 1
|
||||
|
||||
# Build flat list of result dictionaries
|
||||
result = []
|
||||
|
||||
for source in sorted(groups.keys()): # sort displayPath alphabetically
|
||||
for es in sorted(groups[source].keys()): # sort eventState within each path
|
||||
|
||||
result.append([source, es, groups[source][es]])
|
||||
|
||||
return system.dataset.toDataSet(["source", "eventState", "count"], result)
|
||||
Reference in New Issue
Block a user