Parser bug, found by a friend, but I'm submitting it.
Closed this issue · 2 comments
Leimy commented
diff --git a/parse.go b/parse.go
index 9df63133085eb5b670e9aecec71a3b769b2905b8..4a93b17459d72b51ad9d11b6d2853b74c5951f14 100644
--- a/parse.go
+++ b/parse.go
@@ -62,7 +62,7 @@ func parseDateAsString(poll Poll) string {
func parsePoll(state string, poll Poll, topic string) (democrat, republican float64, size int) {
for _, question := range poll.Questions {
- if question.Topic != nil && strings.EqualFold(*question.Topic, topic) {
+ if question.Topic != nil && strings.EqualFold(*question.Topic, topic) && strings.EqualFold(*question.State, state) {
// given multiple subpopulations, prefer likely voters
switch len(question.Subpopulations) {
case 1:
Leimy commented
Latchesar Ionkov was the friend who spotted it.
GaryBoone commented
I've added your fix to the code. Thanks!