I have the following code:
sql = "select Board_Name AS 'Board Name', COUNT(Board_Name) AS 'Count' from dbo.TABLE GROUP BY Board_Name"
result = client.execute(sql)
result.each do |row|
binfo = [ label: row['Board Name'], value: row['Count'] ]
send_event('ticketsbyboard', { items: binfo })
end
I'm trying to get all of the rows passed to the send_event as one array, instead of just one row at a time.
Try a map:
binfo = result.map do |row|
{ label: row['Board Name'], value: row['Count'] }
end
send_event('ticketsbyboard', { items: binfo })
If your result
object doesn't respond directly to map
, just use result.to_a.map