Skip to content

Instantly share code, notes, and snippets.

@proffalken
Created February 14, 2013 13:53
Show Gist options
  • Save proffalken/4952972 to your computer and use it in GitHub Desktop.
Save proffalken/4952972 to your computer and use it in GitHub Desktop.
@msg = @connection.receive
message_body = JSON.parse(@msg.body)[0]['body']
#Resque.enqueue(NrodLookup,message_body)
current_sql_statement = "SELECT nlcdesc FROM tiplocdata WHERE stanox = '#{message_body['reporting_stanox']}'"
next_sql_statement = "SELECT nlcdesc FROM tiplocdata WHERE stanox = '#{message_body['next_report_stanox']}'"
# puts sql_statement
@client.query(current_sql_statement).each do | row |
@current_loc = row['nlcdesc']
end
@client.query(next_sql_statement).each do | row |
@next_loc = row['nlcdesc']
end
time_departed = Time.at(message_body['actual_timestamp'].to_i / 1000)
puts "#{message_body['train_id']} departed #{@current_loc} at #{time_departed} heading to #{@next_loc}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment