Add plugin_reactions_display option

This commit is contained in:
lowlighter
2021-03-09 21:35:22 +01:00
parent 1636f968e2
commit 9a71bb1b8f
2 changed files with 15 additions and 2 deletions

View File

@@ -7,7 +7,7 @@
return null
//Load inputs
let {limit, days, details} = imports.metadata.plugins.reactions.inputs({data, account, q})
let {limit, days, details, display} = imports.metadata.plugins.reactions.inputs({data, account, q})
//Load issue comments
let cursor = null, pushed = 0
@@ -40,8 +40,9 @@
const reactions = comments.flatMap(({reactions}) => reactions)
for (const reaction of reactions)
list[reaction] = (list[reaction] ?? 0) + 1
const max = Math.max(...Object.values(list))
for (const [key, value] of Object.entries(list))
list[key] = {value, score:value/reactions.length}
list[key] = {value, score:value/(display === "relative" ? max : reactions.length)}
//Results
return {list, comments:comments.length, details, days}

View File

@@ -28,6 +28,18 @@ inputs:
default: 0
min: 0
# Reaction display mode.
# Use this option to fill gauges using:
# - "absolute" to use total reactions count
# - "relative" to use highest reaction count
plugin_reactions_display:
description: Display mode
type: string
default: absolute
values:
- absolute
- relative
# Additional details
plugin_reactions_details:
description: Additional details