Skip to content

Commit

Permalink
Updating "no results" message for Civic API integration.
Browse files Browse the repository at this point in the history
Reference: CV2-5456.
  • Loading branch information
caiosba committed Nov 2, 2024
1 parent 9763218 commit 9541296
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/models/tipline_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def handle_user_input(message)

url = "https://www.googleapis.com/civicinfo/v2/voterinfo?key=#{CheckConfig.get('google_api_key')}&address=#{ERB::Util.url_encode(message['text'].to_s.gsub(/\s+/, ' ').gsub(',', ''))}&electionId=9000"
data = JSON.parse(Net::HTTP.get(URI(url)))
return 'Nothing found. Please try again later with this same address or another address.' unless data.has_key?('pollingLocations')
return 'Nothing found. Please try again later with this same address or another address. You can also access state lookups from https://turbovote.org/where-to-vote.' unless data.has_key?('pollingLocations')

output = ['Here are some early vote sites, polling locations and drop-off locations:', '']
output.concat(['*EARLY VOTE SITES*', ''])
Expand All @@ -66,12 +66,12 @@ def handle_user_input(message)
output << "Early vote sites not available.\n" if top_early_vote_sites.blank?

output.concat(['*POLLING LOCATIONS*', ''])
top_polling_locations = data.dig('pollingLocations').first(5)
top_polling_locations = data.dig('pollingLocations').to_a.first(5)
top_polling_locations.each { |location| output << format_location.call(location) }
output << "Top polling locations not available.\n" if top_polling_locations.blank?

output.concat(['*DROP-OFF LOCATIONS*', ''])
top_dropoff_locations = data.dig('dropOffLocations').first(5)
top_dropoff_locations = data.dig('dropOffLocations').to_a.first(5)
top_dropoff_locations.each { |location| output << format_location.call(location) }
output << "Drop-off locations not available.\n" if top_dropoff_locations.blank?

Expand Down

0 comments on commit 9541296

Please sign in to comment.