This repository was archived by the owner on Dec 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
Added == #14
Open
MattLParker
wants to merge
45
commits into
tdmalone:master
Choose a base branch
from
MattLParker:creater/Master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Added == #14
Changes from 43 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
0fdc7f6
Update app.json
RowdyChildren 70aec76
Update messages.js
RowdyChildren 1a01a51
Update events.js
RowdyChildren 48b8296
Update leaderboard.js
RowdyChildren 1a61169
Update points.js
RowdyChildren fc95a3c
whoops
RowdyChildren c9b3f95
added support for emojji
RowdyChildren 6e82a1e
Update helpers.js
RowdyChildren cc720b2
Update events.js
RowdyChildren 3df78b2
Update helpers.js
RowdyChildren 0df6fe7
Update helpers.js
RowdyChildren c3d3f63
added =
MattLParker 5150f54
added ,
MattLParker ffbc86d
updated handler
MattLParker 23658ea
fix casing
MattLParker 461c898
added =
MattLParker 407d1bd
updated messages
MattLParker 2eb44ba
removed spaces
MattLParker 8991055
test remove operation
MattLParker 56bbf10
Revert "test remove operation"
MattLParker cfe97b0
Merge branch 'master' into master
RowdyChildren 08fb59f
test error fix when asking points of bot
MattLParker 685a1aa
removed donothing
MattLParker 1533c3e
add quotes
MattLParker eb2ec66
Merge branch 'Testing'
MattLParker c9f1db8
rebase messages
MattLParker cf86fb7
moved text
MattLParker b1b52d7
undo last
MattLParker 14cf312
added one line
MattLParker c08de65
revert others
MattLParker e7b71cc
Merge branch 'Testing'
MattLParker f85f847
changed to creater/master
MattLParker 9980aaf
further rebase
MattLParker dd6b91f
fixing some "errors"
MattLParker 6e00348
extra }
MattLParker 64d28af
missing comma
MattLParker ce8a96b
changed to uppercase
MattLParker da15093
Check without uppercase
MattLParker 15a0098
added =
MattLParker cc3e4b1
fixed spaces
MattLParker ab34559
remove operation
MattLParker afa61a8
one last stupid space
MattLParker 37c8d2c
oops
MattLParker 5994f1d
added help, refactored to lowercase g in getScore
MattLParker 0f0d952
removed Site specific
MattLParker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -93,7 +93,44 @@ const updateScore = async( item, operation ) => { | |
|
|
||
| }; // UpdateScore. | ||
|
|
||
| /** | ||
| * Gets score | ||
| * into the database with an assumed initial score of 0. | ||
| * | ||
| * This function also sets up the database if it is not already ready, including creating the | ||
| * scores table and activating the Postgres case-insensitive extension. | ||
| * | ||
| * @param {string} item The Slack user ID (if user) or name (if thing) of the item being | ||
| * operated on. | ||
| * @param {string} operation The mathematical operation performed on the item's score. | ||
| * @return {int} The item's new score after the update has been applied. | ||
| */ | ||
| const GetScore = async( item ) => { | ||
|
||
|
|
||
| // Connect to the DB, and create a table if it's not yet there. | ||
| // We also set up the citext extension, so that we can easily be case insensitive. | ||
| const dbClient = await postgres.connect(); | ||
| await dbClient.query( '\ | ||
| CREATE EXTENSION IF NOT EXISTS citext; \ | ||
| CREATE TABLE IF NOT EXISTS ' + scoresTableName + ' (item CITEXT PRIMARY KEY, score INTEGER); \ | ||
| ' ); | ||
|
|
||
| // Get the new value. | ||
| // TODO: Fix potential SQL injection issues here, even though we know the input should be safe. | ||
| const dbSelect = await dbClient.query( '\ | ||
| SELECT score FROM ' + scoresTableName + ' WHERE item = \'' + item + '\'; \ | ||
| ' ); | ||
|
|
||
| await dbClient.release(); | ||
| const score = dbSelect.rows[0].score; | ||
|
|
||
| console.log( item + ' now on ' + score ); | ||
| return score; | ||
|
|
||
| }; // UpdateScore. | ||
|
|
||
| module.exports = { | ||
| retrieveTopScores, | ||
| updateScore | ||
| updateScore, | ||
| GetScore | ||
| }; | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you've also joined the cult of the shifty. One of us! One of us! One of us!