From 9a71bb1b8f292a4d84487c44e579fab3e14b8f82 Mon Sep 17 00:00:00 2001 From: lowlighter <22963968+lowlighter@users.noreply.github.com> Date: Tue, 9 Mar 2021 21:35:22 +0100 Subject: [PATCH] Add plugin_reactions_display option --- source/plugins/reactions/index.mjs | 5 +++-- source/plugins/reactions/metadata.yml | 12 ++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/source/plugins/reactions/index.mjs b/source/plugins/reactions/index.mjs index 56d7dec5..e2b46d80 100644 --- a/source/plugins/reactions/index.mjs +++ b/source/plugins/reactions/index.mjs @@ -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} diff --git a/source/plugins/reactions/metadata.yml b/source/plugins/reactions/metadata.yml index 144a1986..9cb7ac08 100644 --- a/source/plugins/reactions/metadata.yml +++ b/source/plugins/reactions/metadata.yml @@ -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