Skip to content

Commit

Permalink
fix: add PushEvent to activity
Browse files Browse the repository at this point in the history
  • Loading branch information
Qu4k committed Jul 21, 2020
1 parent ba88503 commit 830a417
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
32 changes: 13 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,10 @@ displays as:

##### Configuration

```jsonc
{
"rows": 12, // default 5
"raw": true // Strip markdown formatting. default false.
}
```
| option | value | default | description |
| ------ | ------- | --------- | ----------- |
| rows | string | `10` | Maximum number of rows to generate. |
| raw | boolean | `false` | Strip markdown formatting. |

#### GitHub Repos

Expand All @@ -97,13 +95,11 @@ displays as:

##### Configuration

```jsonc
{
"rows": 12, // default 5
"sort": "created", // default "stars"
"raw": true // Strip markdown formatting. default false.
}
```
| option | value | default | description |
| ------ | ------- | --------- | ----------- |
| rows | string | `10` | Maximum number of rows to generate. |
| sort | string | `"stars"` | Sort repositories by "stars", "created", "updated", "pushed", "full_name". |
| raw | boolean | `false` | Strip markdown formatting. |

#### Current Timestamp

Expand All @@ -121,12 +117,10 @@ Tuesday, July 21st 2020, 8:52:54 am UTC

##### Configuration

```jsonc
{
"format": "h:mm:ss", // default is ISO 8601,
"tz": "America/New_York" // default none (UTC)
}
```
| option | value | default | description |
| ------ | ------- | -------- | ----------- |
| format | string | ISO 8601 | moment [format](https://momentjs.com/docs/#/displaying/). |
| tz | boolean | UTC | moment [timezone](https://momentjs.com/timezone/docs/#/using-timezones/). |

### Inputs

Expand Down
8 changes: 7 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10880,6 +10880,12 @@ const serializers = {
},
ReleaseEvent: item => {
return `📦 Released "${item.payload.release.name}" in ${item.repo.name}`;
},
PushEvent: item => {
const commits = item.payload.size > 1
? `${item.payload.size} commits`
: `${item.payload.size} commit`;
return `⬆️ Pushed ${commits} to ${item.repo.name}`;
}
};
function serialize(item, raw) {
Expand All @@ -10892,7 +10898,7 @@ function activity(events, widget) {
var _a;
const content = events.data
.filter(event => serializers.hasOwnProperty(event.type))
.slice(0, (_a = widget.config.rows) !== null && _a !== void 0 ? _a : 5)
.slice(0, (_a = widget.config.rows) !== null && _a !== void 0 ? _a : 10)
.map(item => serialize(item, widget.config.raw))
.join("\n");
return content;
Expand Down
8 changes: 7 additions & 1 deletion src/widgets/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ const serializers = {
},
ReleaseEvent: item => {
return `📦 Released "${item.payload.release.name}" in ${item.repo.name}`;
},
PushEvent: item => {
const commits = item.payload.size > 1
? `${item.payload.size} commits`
: `${item.payload.size} commit`
return `⬆️ Pushed ${commits} to ${item.repo.name}`;
}
};

Expand All @@ -39,7 +45,7 @@ function serialize(item, raw: boolean | undefined): string {
export function activity(events: any, widget: Widget<ActivityConfig>): string {
const content = events.data
.filter(event => serializers.hasOwnProperty(event.type))
.slice(0, widget.config.rows ?? 5)
.slice(0, widget.config.rows ?? 10)
.map(item => serialize(item, widget.config.raw))
.join("\n");
return content;
Expand Down

0 comments on commit 830a417

Please sign in to comment.