Skip to content

Commit

Permalink
fix: Time parse fix (#178)
Browse files Browse the repository at this point in the history
* Adding some event object handlers and modifying tests to match expectations

* Helper date/str management

* Bump and oss

* Fix timezone test issue
  • Loading branch information
O-Mutt committed Jan 6, 2024
1 parent 5e1813c commit 5404402
Show file tree
Hide file tree
Showing 14 changed files with 663 additions and 405 deletions.
55 changes: 35 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@
hubot-plusplus-expanded
==============
# hubot-plusplus-expanded

---

[![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)
[![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)

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

## API

API
---
* \<name>++ [\<reason>] - Increment score for a name (for a reason)
* \<name>-- [\<reason>] - Decrement score for a name (for a reason)
* {name1, name2, name3}++ [\<reason>] - Increment score for all names (for a reason)
* {name1, name2, name3}-- [\<reason>] - Decrement score for all names (for a reason)
* hubot score <name> - Display the score for a name and some of the reasons
* hubot top <amount> - Display the top scoring <amount>
* hubot bottom <amount> - Display the bottom scoring <amount>
* hubot erase <name> [\<reason>] - Remove the score for a name (for a reason)
* how much are hubot points worth (how much point) - Shows how much hubot points are worth

* `<name>++ [<reason>]` - Increment score for a name (for a reason)
* `<name>-- [<reason>]` - Decrement score for a name (for a reason)
* `{name1, name2, name3}++ [<reason>]` - Increment score for all names (for a reason)
* `{name1, name2, name3}-- [<reason>]` - Decrement score for all names (for a reason)
* `<bot_name> score <name>` - Display the score for a name and some of the reasons
* `bot_name top <amount>` - Display the top scoring <amount>
* `bot_name bottom <amount>` - Display the bottom scoring <amount>
* `bot_name erase <name> [<reason>]` - Remove the score for a name (for a reason)
* `how much are bot_name points worth (how much point)` - Shows how much hubot points are worth

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

```coffeescript
robot.emit "plus-plus", {
name: 'Jack'
direction: '++' # (or --)
room: 'chatRoomAlpha'
reason: 'being awesome'
}
[PlusPlusEvent Class](./src/events/PlusPlusEvent.js)

```javascript
robot.emit("plus-plus",
[
{
name: 'Jack'
direction: '++' # (or --)
room: 'chatRoomAlpha'
reason: 'being awesome'
}
]);
```

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

["hubot-plusplus-expanded"]
```json
["hubot-plusplus-expanded"]
```

## Configuration

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

## Mongo data Layout

``` javascript
scores: [
{
Expand Down Expand Up @@ -103,11 +113,16 @@ PointsGivenObject:

## Testing

All the unit tests are run using `jest`

Individual run:
`npm run test`

Tdd:
`npm run test:watch`

You can use `npm run test -- --testPathPattern=helpers.test.js` to test a specific file or any other cli options that jest has available

## Known issue

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": {} });`
Loading

0 comments on commit 5404402

Please sign in to comment.