Skip to content

Commit 5404402

Browse files
authored
fix: Time parse fix (#178)
* Adding some event object handlers and modifying tests to match expectations * Helper date/str management * Bump and oss * Fix timezone test issue
1 parent 5e1813c commit 5404402

14 files changed

Lines changed: 663 additions & 405 deletions

README.md

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,41 @@
1-
hubot-plusplus-expanded
2-
==============
1+
# hubot-plusplus-expanded
2+
3+
---
34

45
[![Known Vulnerabilities](https://snyk.io//test/github/Mutmatt/hubot-plusplus-expanded/badge.svg?targetFile=package.json)](https://snyk.io//test/github/Mutmatt/hubot-plusplus-expanded?targetFile=package.json)
56
[![Node CI](https://github.com/O-Mutt/hubot-plusplus-expanded/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/O-Mutt/hubot-plusplus-expanded/actions/workflows/test.yml)
67

78
Give or take away points. Keeps track and even prints out graphs.
89

10+
## API
911

10-
API
1112
---
12-
* \<name>++ [\<reason>] - Increment score for a name (for a reason)
13-
* \<name>-- [\<reason>] - Decrement score for a name (for a reason)
14-
* {name1, name2, name3}++ [\<reason>] - Increment score for all names (for a reason)
15-
* {name1, name2, name3}-- [\<reason>] - Decrement score for all names (for a reason)
16-
* hubot score <name> - Display the score for a name and some of the reasons
17-
* hubot top <amount> - Display the top scoring <amount>
18-
* hubot bottom <amount> - Display the bottom scoring <amount>
19-
* hubot erase <name> [\<reason>] - Remove the score for a name (for a reason)
20-
* how much are hubot points worth (how much point) - Shows how much hubot points are worth
13+
14+
* `<name>++ [<reason>]` - Increment score for a name (for a reason)
15+
* `<name>-- [<reason>]` - Decrement score for a name (for a reason)
16+
* `{name1, name2, name3}++ [<reason>]` - Increment score for all names (for a reason)
17+
* `{name1, name2, name3}-- [<reason>]` - Decrement score for all names (for a reason)
18+
* `<bot_name> score <name>` - Display the score for a name and some of the reasons
19+
* `bot_name top <amount>` - Display the top scoring <amount>
20+
* `bot_name bottom <amount>` - Display the bottom scoring <amount>
21+
* `bot_name erase <name> [<reason>]` - Remove the score for a name (for a reason)
22+
* `how much are bot_name points worth (how much point)` - Shows how much hubot points are worth
2123

2224
Uses Hubot brain. Also exposes the following events, should you wish to hook
2325
into it to do things like print out funny gifs for point streaks:
2426

25-
```coffeescript
26-
robot.emit "plus-plus", {
27-
name: 'Jack'
28-
direction: '++' # (or --)
29-
room: 'chatRoomAlpha'
30-
reason: 'being awesome'
31-
}
27+
[PlusPlusEvent Class](./src/events/PlusPlusEvent.js)
28+
29+
```javascript
30+
robot.emit("plus-plus",
31+
[
32+
{
33+
name: 'Jack'
34+
direction: '++' # (or --)
35+
room: 'chatRoomAlpha'
36+
reason: 'being awesome'
37+
}
38+
]);
3239
```
3340

3441
## Installation
@@ -46,7 +53,9 @@ Then to make sure the dependencies are installed:
4653
To enable the script, add a `hubot-plusplus-expanded` entry to the `external-scripts.json`
4754
file (you may need to create this file).
4855

49-
["hubot-plusplus-expanded"]
56+
```json
57+
["hubot-plusplus-expanded"]
58+
```
5059

5160
## Configuration
5261

@@ -72,6 +81,7 @@ Some of the behavior of this plugin is configured in the environment:
7281
`db.scoreLog.createIndex( { "date": 1 }, { expireAfterSeconds: 5 } )`
7382

7483
## Mongo data Layout
84+
7585
``` javascript
7686
scores: [
7787
{
@@ -103,11 +113,16 @@ PointsGivenObject:
103113

104114
## Testing
105115

116+
All the unit tests are run using `jest`
117+
106118
Individual run:
107119
`npm run test`
108120

109121
Tdd:
110122
`npm run test:watch`
111123

124+
You can use `npm run test -- --testPathPattern=helpers.test.js` to test a specific file or any other cli options that jest has available
125+
112126
## Known issue
127+
113128
As of now there is an issue that has shown up a couple times without a root cause. The `$setOnInsert` excludes the `reasons: {}` object. The fix, currently, is to identify the bad document in mongo `db.scores.find({ "reasons: null"});` and update them `db.scores.updateMany({ "reasons: null"}, { $set: { "reasons": {} });`

0 commit comments

Comments
 (0)