The great refactor (#82)
This commit is contained in:
44
source/plugins/activity/README.md
Normal file
44
source/plugins/activity/README.md
Normal file
@@ -0,0 +1,44 @@
|
||||
### 📰 Recent activity
|
||||
|
||||
The *activity* plugin displays your recent activity on GitHub.
|
||||
|
||||
<table>
|
||||
<td align="center">
|
||||
<img src="https://github.com/lowlighter/lowlighter/blob/master/metrics.plugin.activity.svg">
|
||||
<img width="900" height="1" alt="">
|
||||
</td>
|
||||
</table>
|
||||
|
||||
It uses data from [GitHub events](https://docs.github.com/en/free-pro-team@latest/developers/webhooks-and-events/github-event-types) and is able to track the following events:
|
||||
|
||||
| Event | Description |
|
||||
| ------------ | ----------------------------------------------- |
|
||||
| `push` | Push of commits |
|
||||
| `issue` | Opening/Reopening/Closing of issues |
|
||||
| `pr` | Opening/Closing of pull requests |
|
||||
| `ref/create` | Creation of git tags or git branches |
|
||||
| `ref/delete` | Deletion of git tags or git branches |
|
||||
| `release` | Publication of new releases |
|
||||
| `review` | Review of pull requests |
|
||||
| `comment` | Comments on commits, issues and pull requests |
|
||||
| `wiki` | Edition of wiki pages |
|
||||
| `fork` | Forking of repositories |
|
||||
| `star` | Starring of repositories |
|
||||
| `public` | Repositories made public |
|
||||
| `member` | Addition of new collaborator in repository |
|
||||
|
||||
Use a full `repo` scope token to display **private** events.
|
||||
|
||||
#### ℹ️ Examples workflows
|
||||
|
||||
[➡️ Available options for this plugin](metadata.yml)
|
||||
|
||||
```yaml
|
||||
- uses: lowlighter/metrics@latest
|
||||
with:
|
||||
# ... other options
|
||||
plugin_activity: yes
|
||||
plugin_activity_limit: 5 # Limit to 5 events
|
||||
plugin_activity_days: 14 # Keep only events from last 14 days (can be set to 0 to disable limitations)
|
||||
plugin_activity_filter: all # Show all events (use table above to filter events types)
|
||||
```
|
||||
@@ -1,24 +1,21 @@
|
||||
//Setup
|
||||
export default async function ({login, rest, q, account}, {enabled = false} = {}) {
|
||||
export default async function ({login, data, rest, q, account, imports}, {enabled = false} = {}) {
|
||||
//Plugin execution
|
||||
try {
|
||||
//Check if plugin is enabled and requirements are met
|
||||
if ((!enabled)||(!q.activity))
|
||||
return null
|
||||
|
||||
//Parameters override
|
||||
let {"activity.limit":limit = 5, "activity.days":days = 7, "activity.filter":filter = "all"} = q
|
||||
//Events
|
||||
limit = Math.max(1, Math.min(100, Number(limit)))
|
||||
//Days
|
||||
days = Number(days) > 0 ? Number(days) : Infinity
|
||||
//Filtered events
|
||||
filter = decodeURIComponent(filter).split(",").map(x => x.trim().toLocaleLowerCase()).filter(x => x)
|
||||
//Load inputs
|
||||
let {limit, days, filter} = imports.metadata.plugins.activity.inputs({data, q, account})
|
||||
if (!days)
|
||||
days = Infinity
|
||||
|
||||
//Get user recent activity
|
||||
console.debug(`metrics/compute/${login}/plugins > activity > querying api`)
|
||||
const {data:events} = await rest.activity.listEventsForAuthenticatedUser({username:login, per_page:100})
|
||||
console.debug(`metrics/compute/${login}/plugins > activity > ${events.length} events loaded`)
|
||||
|
||||
//Extract activity events
|
||||
const activity = events
|
||||
.filter(({actor}) => account === "organization" ? true : actor.login === login)
|
||||
|
||||
51
source/plugins/activity/metadata.yml
Normal file
51
source/plugins/activity/metadata.yml
Normal file
@@ -0,0 +1,51 @@
|
||||
name: "📰 Recent activity"
|
||||
cost: 1 REST request per 100 events
|
||||
supports:
|
||||
- user
|
||||
- organization
|
||||
inputs:
|
||||
|
||||
# Enable or disable plugin
|
||||
plugin_activity:
|
||||
description: Display recent activity
|
||||
type: boolean
|
||||
default: no
|
||||
|
||||
# Number of activity events to display
|
||||
plugin_activity_limit:
|
||||
description: Maximum number of events to display
|
||||
type: number
|
||||
default: 5
|
||||
min: 1
|
||||
max: 100
|
||||
|
||||
# Filter events by age
|
||||
# Set to 0 to disable age filtering
|
||||
plugin_activity_days:
|
||||
description: Maximum event age
|
||||
type: number
|
||||
default: 14
|
||||
min: 0
|
||||
max: 365
|
||||
|
||||
# Filter events by type
|
||||
plugin_activity_filter:
|
||||
description: Events types to keep
|
||||
type: array
|
||||
format: comma-separated
|
||||
default: all
|
||||
values:
|
||||
- all # Display all types of events
|
||||
- comment # Display commits, issues and pull requests comments
|
||||
- ref/create # Display tags and branches creations
|
||||
- ref/delete # Display tags and branches deletions
|
||||
- release # Display published releases
|
||||
- push # Display commits
|
||||
- issue # Display issues events
|
||||
- pr # Display pull requests events
|
||||
- review # Display pull request reviews
|
||||
- wiki # Display wiki editions
|
||||
- fork # Display forked repositories
|
||||
- star # Display starred repositories
|
||||
- member # Display collaborators additions
|
||||
- public # Display repositories made public
|
||||
Reference in New Issue
Block a user