Skip to content

Commit

Permalink
Updating give points logic
Browse files Browse the repository at this point in the history
  • Loading branch information
O-Mutt committed Jun 4, 2021
1 parent 839292f commit 62e137e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hubot-plusplus-expanded",
"version": "2.2.1",
"version": "2.2.2",
"description": "A hubot script for micro praise",
"main": "index.js",
"engines": {
Expand Down
7 changes: 4 additions & 3 deletions src/services/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ class DatabaseService {
const fromUser = await this.getUser(from.name);

const oldScore = fromUser.pointsGiven[cleanName] ? fromUser.pointsGiven[cleanName] : 0;
fromUser.pointsGiven[cleanName] = (oldScore + score);
// even if they are down voting them they should still get a tally as they ++/-- the same person
fromUser.pointsGiven[cleanName] = (oldScore + 1);
const result = await db.collection(scoresDocumentName)
.findOneAndUpdate(
{ name: fromUser.name },
Expand All @@ -147,8 +148,8 @@ class DatabaseService {
);
const updatedUser = result.value;

if (updatedUser.pointsGiven[cleanName] % this.furtherFeedbackScore === 0 && score === 1) {
this.robot.logger.debug(`${from.name} has sent a lot of points to ${to.name} suggesting further feedback`);
if (updatedUser.pointsGiven[cleanName] % this.furtherFeedbackScore === 0) {
this.robot.logger.debug(`${from.name} has sent a lot of points to ${to.name} suggesting further feedback ${score}`);
this.robot.messageRoom(from.id, `Looks like you've given ${to.name} quite a few points, maybe you should look at submitting ${this.peerFeedbackUrl}`);
}
}
Expand Down

0 comments on commit 62e137e

Please sign in to comment.