Convert reactionGroups to a flat dict, dropping zeros.
(reaction_groups: list)
| 82 | |
| 83 | |
| 84 | def transform_reactions(reaction_groups: list) -> dict: |
| 85 | """Convert reactionGroups to a flat dict, dropping zeros.""" |
| 86 | reactions = {} |
| 87 | for rg in reaction_groups: |
| 88 | count = rg["users"]["totalCount"] |
| 89 | if count > 0: |
| 90 | reactions[rg["content"]] = count |
| 91 | return reactions |
| 92 | |
| 93 | |
| 94 | def transform_timeline_event(event: dict) -> dict | None: |