comment_vote.go: clean up SQL

This commit is contained in:
Adhityaa Chandrasekar 2019-12-27 17:27:47 -08:00
parent e0504a0c88
commit e7a5e01379

View File

@ -28,12 +28,12 @@ func commentVote(commenterHex string, commentHex string, direction int) error {
} }
statement = ` statement = `
INSERT INTO INSERT INTO
votes (commentHex, commenterHex, direction, voteDate) votes (commentHex, commenterHex, direction, voteDate)
VALUES ($1, $2, $3, $4 ) VALUES ($1, $2, $3, $4 )
ON CONFLICT (commentHex, commenterHex) DO ON CONFLICT (commentHex, commenterHex) DO
UPDATE SET direction = $3; UPDATE SET direction = $3;
` `
_, err := db.Exec(statement, commentHex, commenterHex, direction, time.Now().UTC()) _, err := db.Exec(statement, commentHex, commenterHex, direction, time.Now().UTC())
if err != nil { if err != nil {
logger.Errorf("error inserting/updating votes: %v", err) logger.Errorf("error inserting/updating votes: %v", err)