Add plugin_reactions_limit_issues (#334)
This commit is contained in:
@@ -19,6 +19,7 @@ The *reactions* plugin displays overall reactions on your recent issues and issu
|
|||||||
# ... other options
|
# ... other options
|
||||||
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_limit_issues: 100 # Compute reactions over laste 100 issues/pull requests opened
|
||||||
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: count, percentage # Display reactions count and percentage
|
plugin_reactions_details: count, percentage # Display reactions count and percentage
|
||||||
plugin_reactions_ignored: bot # Ignore "bot" user
|
plugin_reactions_ignored: bot # Ignore "bot" user
|
||||||
|
|||||||
@@ -7,12 +7,13 @@ export default async function({login, q, imports, data, graphql, queries, accoun
|
|||||||
return null
|
return null
|
||||||
|
|
||||||
//Load inputs
|
//Load inputs
|
||||||
let {limit, days, details, display, ignored} = imports.metadata.plugins.reactions.inputs({data, account, q})
|
let {limit:_limit1, "limit.issues":_limit2, days, details, display, ignored} = imports.metadata.plugins.reactions.inputs({data, account, q})
|
||||||
|
|
||||||
//Load issue comments
|
//Load issue comments
|
||||||
let cursor = null, pushed = 0
|
|
||||||
const comments = []
|
const comments = []
|
||||||
for (const type of ["issues", "issueComments"]) {
|
for (const {type, limit} of [{type:"issueComments", limit:_limit1}, {type:"issues", limit:_limit2}].filter(({limit}) => limit)) {
|
||||||
|
let cursor = null, pushed = 0
|
||||||
|
const fetched = []
|
||||||
do {
|
do {
|
||||||
//Load issue comments
|
//Load issue comments
|
||||||
console.debug(`metrics/compute/${login}/plugins > reactions > retrieving ${type} after ${cursor}`)
|
console.debug(`metrics/compute/${login}/plugins > reactions > retrieving ${type} after ${cursor}`)
|
||||||
@@ -23,19 +24,17 @@ export default async function({login, q, imports, data, graphql, queries, accoun
|
|||||||
.flatMap(({node:{createdAt:created, reactions:{nodes:reactions}}}) => ({created:new Date(created), reactions:reactions.filter(({user = {}}) => !ignored.includes(user.login)).map(({content}) => content)}))
|
.flatMap(({node:{createdAt:created, reactions:{nodes:reactions}}}) => ({created:new Date(created), reactions:reactions.filter(({user = {}}) => !ignored.includes(user.login)).map(({content}) => content)}))
|
||||||
.filter(comment => Number.isFinite(days) ? comment.created < new Date(Date.now() - days * 24 * 60 * 60 * 1000) : true)
|
.filter(comment => Number.isFinite(days) ? comment.created < new Date(Date.now() - days * 24 * 60 * 60 * 1000) : true)
|
||||||
pushed = filtered.length
|
pushed = filtered.length
|
||||||
comments.push(...filtered)
|
fetched.push(...filtered)
|
||||||
console.debug(`metrics/compute/${login}/plugins > reactions > currently at ${comments.length} comments`)
|
console.debug(`metrics/compute/${login}/plugins > reactions > currently at ${fetched.length} ${type} comments`)
|
||||||
//Early break
|
|
||||||
if ((comments.length >= limit) || (filtered.length < edges.length))
|
|
||||||
break
|
|
||||||
} while ((cursor) && (pushed) && (comments.length < limit))
|
|
||||||
}
|
|
||||||
|
|
||||||
//Applying limit
|
//Applying limit
|
||||||
if (limit) {
|
if ((fetched.length >= limit) || (filtered.length < edges.length)) {
|
||||||
comments.splice(limit)
|
fetched.splice(limit)
|
||||||
console.debug(`metrics/compute/${login}/plugins > reactions > keeping only ${comments.length} comments`)
|
console.debug(`metrics/compute/${login}/plugins > reactions > keeping only ${fetched.length} ${type} comments`)
|
||||||
}
|
}
|
||||||
|
} while ((cursor) && (pushed) && (fetched.length < limit))
|
||||||
|
comments.push(...fetched)
|
||||||
|
}
|
||||||
|
console.debug(`metrics/compute/${login}/plugins > reactions > fetched ${comments.length} comments`)
|
||||||
|
|
||||||
//Format reactions list
|
//Format reactions list
|
||||||
const list = {}
|
const list = {}
|
||||||
|
|||||||
@@ -13,12 +13,19 @@ inputs:
|
|||||||
default: no
|
default: no
|
||||||
|
|
||||||
# Maximum number of issue comments to parse
|
# Maximum number of issue comments to parse
|
||||||
# Issues will be fetched before issues comments
|
|
||||||
plugin_reactions_limit:
|
plugin_reactions_limit:
|
||||||
description: Maximum number of issue comments to parse
|
description: Maximum number of issue comments to parse
|
||||||
type: number
|
type: number
|
||||||
default: 200
|
default: 200
|
||||||
min: 1
|
min: 0
|
||||||
|
max: 1000
|
||||||
|
|
||||||
|
# Maximum number of issues and pull requests opened to parse
|
||||||
|
plugin_reactions_limit_issues:
|
||||||
|
description: Maximum number of issues and pull requests opened to parse
|
||||||
|
type: number
|
||||||
|
default: 100
|
||||||
|
min: 0
|
||||||
max: 1000
|
max: 1000
|
||||||
|
|
||||||
# Filter reactions by issue comments age
|
# Filter reactions by issue comments age
|
||||||
|
|||||||
Reference in New Issue
Block a user