Add plugin_reactions_display option
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
return null
|
return null
|
||||||
|
|
||||||
//Load inputs
|
//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
|
//Load issue comments
|
||||||
let cursor = null, pushed = 0
|
let cursor = null, pushed = 0
|
||||||
@@ -40,8 +40,9 @@
|
|||||||
const reactions = comments.flatMap(({reactions}) => reactions)
|
const reactions = comments.flatMap(({reactions}) => reactions)
|
||||||
for (const reaction of reactions)
|
for (const reaction of reactions)
|
||||||
list[reaction] = (list[reaction] ?? 0) + 1
|
list[reaction] = (list[reaction] ?? 0) + 1
|
||||||
|
const max = Math.max(...Object.values(list))
|
||||||
for (const [key, value] of Object.entries(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
|
//Results
|
||||||
return {list, comments:comments.length, details, days}
|
return {list, comments:comments.length, details, days}
|
||||||
|
|||||||
@@ -28,6 +28,18 @@ inputs:
|
|||||||
default: 0
|
default: 0
|
||||||
min: 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
|
# Additional details
|
||||||
plugin_reactions_details:
|
plugin_reactions_details:
|
||||||
description: Additional details
|
description: Additional details
|
||||||
|
|||||||
Reference in New Issue
Block a user