Add support to display both count and percentage on reaction plugins
This commit is contained in:
@@ -179,14 +179,14 @@
|
|||||||
...(set.plugins.enabled.reactions ? ({
|
...(set.plugins.enabled.reactions ? ({
|
||||||
reactions:{
|
reactions:{
|
||||||
list:{
|
list:{
|
||||||
HEART:{value:faker.random.number(100), score:faker.random.number(100)/100},
|
HEART:{value:faker.random.number(100), get percentage() { return this.score }, score:faker.random.number(100)/100},
|
||||||
THUMBS_UP:{value:faker.random.number(100), score:faker.random.number(100)/100},
|
THUMBS_UP:{value:faker.random.number(100), get percentage() { return this.score }, score:faker.random.number(100)/100},
|
||||||
THUMBS_DOWN:{value:faker.random.number(100), score:faker.random.number(100)/100},
|
THUMBS_DOWN:{value:faker.random.number(100), get percentage() { return this.score }, score:faker.random.number(100)/100},
|
||||||
LAUGH:{value:faker.random.number(100), score:faker.random.number(100)/100},
|
LAUGH:{value:faker.random.number(100), get percentage() { return this.score }, score:faker.random.number(100)/100},
|
||||||
CONFUSED:{value:faker.random.number(100), score:faker.random.number(100)/100},
|
CONFUSED:{value:faker.random.number(100), get percentage() { return this.score }, score:faker.random.number(100)/100},
|
||||||
EYES:{value:faker.random.number(100), score:faker.random.number(100)/100},
|
EYES:{value:faker.random.number(100), get percentage() { return this.score }, score:faker.random.number(100)/100},
|
||||||
ROCKET:{value:faker.random.number(100), score:faker.random.number(100)/100},
|
ROCKET:{value:faker.random.number(100), get percentage() { return this.score }, score:faker.random.number(100)/100},
|
||||||
HOORAY:{value:faker.random.number(100), score:faker.random.number(100)/100},
|
HOORAY:{value:faker.random.number(100), get percentage() { return this.score }, score:faker.random.number(100)/100},
|
||||||
},
|
},
|
||||||
comments:options["reactions.limit"],
|
comments:options["reactions.limit"],
|
||||||
details:options["reactions.details"],
|
details:options["reactions.details"],
|
||||||
|
|||||||
@@ -20,5 +20,5 @@ The *reactions* plugin displays overall reactions on your recent issues and issu
|
|||||||
plugin_reactions: yes
|
plugin_reactions: yes
|
||||||
plugin_reactions_limit: 200 # Compute reactions over last 200 issue comments
|
plugin_reactions_limit: 200 # Compute reactions over last 200 issue comments
|
||||||
plugin_reactions_days: 14 # Compute reactions on issue comments posted less than 14 days ago
|
plugin_reactions_days: 14 # Compute reactions on issue comments posted less than 14 days ago
|
||||||
plugin_reactions_details: percentage # Display reactions percentage
|
plugin_reactions_details: count, percentage # Display reactions count and percentage
|
||||||
```
|
```
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
list[reaction] = (list[reaction] ?? 0) + 1
|
list[reaction] = (list[reaction] ?? 0) + 1
|
||||||
const max = Math.max(...Object.values(list))
|
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/(display === "relative" ? max : reactions.length)}
|
list[key] = {value, percentage:value/reactions.length, score:value/(display === "relative" ? max : reactions.length)}
|
||||||
|
|
||||||
//Results
|
//Results
|
||||||
return {list, comments:comments.length, details, days, twemoji:q["config.twemoji"]}
|
return {list, comments:comments.length, details, days, twemoji:q["config.twemoji"]}
|
||||||
|
|||||||
@@ -41,11 +41,13 @@ inputs:
|
|||||||
- relative
|
- relative
|
||||||
|
|
||||||
# Additional details
|
# Additional details
|
||||||
|
# If multiple values are specified, emphasis will be set on first value
|
||||||
plugin_reactions_details:
|
plugin_reactions_details:
|
||||||
description: Additional details
|
description: Additional details
|
||||||
type: string
|
type: array
|
||||||
default: none
|
format: comma-separated
|
||||||
|
default: ""
|
||||||
|
example: count, percentage
|
||||||
values:
|
values:
|
||||||
- none
|
|
||||||
- count
|
- count
|
||||||
- percentage
|
- percentage
|
||||||
@@ -41,10 +41,23 @@
|
|||||||
<% } %>
|
<% } %>
|
||||||
<% } %>
|
<% } %>
|
||||||
</svg>
|
</svg>
|
||||||
<% if (plugins.reactions.details === "percentage") { %>
|
<% if (plugins.reactions.details.length) { const [primary, secondary] = plugins.reactions.details %>
|
||||||
<span class="title"><%= Math.round(score*100) %><small>%</small></span>
|
<span class="title">
|
||||||
<% } else if (plugins.reactions.details === "count") { %>
|
<% if (primary === "count") { %>
|
||||||
<span class="title"><%= count %></span>
|
<%= count %>
|
||||||
|
<% } else if (primary === "percentage") { %>
|
||||||
|
<%= Math.round(score*100) %><small>%</small>
|
||||||
|
<% } %>
|
||||||
|
<% if (secondary) { %>
|
||||||
|
<small>
|
||||||
|
<% if (secondary === "count") { %>
|
||||||
|
(<%= count %>)
|
||||||
|
<% } else if (secondary === "percentage") { %>
|
||||||
|
(<%= Math.round(score*100) %><small>%</small>)
|
||||||
|
<% } %>
|
||||||
|
</small>
|
||||||
|
<% } %>
|
||||||
|
</span>
|
||||||
<% } %>
|
<% } %>
|
||||||
</div>
|
</div>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|||||||
Reference in New Issue
Block a user