diff options
author | Joe Robinson <joe@mumsnet.com> | 2014-07-25 15:41:58 +0100 |
---|---|---|
committer | Joe Robinson <joe@mumsnet.com> | 2014-07-25 15:41:58 +0100 |
commit | 07884e5c9b4fe423d10b1f4a9b6366f7d81cffb2 (patch) | |
tree | 02ad9caed8e5b5fe251d92bac53e2dbc639ddefd | |
parent | bf720d0d1ae4e9e20e34bd63c45252468b6fdd6c (diff) |
Fixed voting to only vote for options for the given poll
-rw-r--r-- | blavote.go | 4 | ||||
-rw-r--r-- | option.go | 6 |
2 files changed, 5 insertions, 5 deletions
@@ -14,7 +14,7 @@ var version string func main() { - version = "0.7" + version = "0.7.1" //Command line arguments var opts struct { @@ -155,7 +155,7 @@ func vote(db *sqlite3.Conn, nick string, options []string) error { return err } - option, err := getOptionFromText(db, options[1]) + option, err := getOptionFromText(db, options[1], pollId) if (err != nil) { return err @@ -10,10 +10,10 @@ type Option struct { numVotes int64 } -func getOptionFromText(db*sqlite3.Conn, text string) (Option, error) { +func getOptionFromText(db*sqlite3.Conn, text string, id int) (Option, error) { - args := sqlite3.NamedArgs{"$a": text} - sql := "SELECT * FROM options WHERE text = $a" + args := sqlite3.NamedArgs{"$a": text, "$b": id} + sql := "SELECT * FROM options WHERE text = $a and poll_id = $b" s, err := db.Query(sql, args) row := make(sqlite3.RowMap) |