I've been beating my head against this issue for a bit and am looking for some help. I have a Dashing Wallboard that has been working great. I am trying to add a widget that shows a list of data, but no data ever shows up in the widget nor the history.yml file.
The rest of my widgets are pulling data from the same SQL server, that's why the connection information is omitted below:
I have the following code in my .rb job file:
results = client.execute("
SELECT [data] as name, [data2] as value
FROM [DB]
Where [Conditions]
GROUP BY [Tier];
")
datalist = results.map do |row|
row = {
:label => row['name'],
:value => row['value']
}
end
send_event('listofdata', { items: datalist } )
My dashboard widget looks like this:
<li data-row="2" data-col="3" data-sizex="1" data-sizey="2">
<div data-id="listofdata" data-view="List" data-title="This is a list of data" data-unordered="true"></div>
</li>
The output from my SQL query looks like this:
Tier 1 10
Tier2 6
Tier 3 31
The data types are varchar and int. I did include spaces and no spaces in the name column to show that the results of the query do contains spaces.
I have also tried doing the ruby side like this but it still didn't work.
results.each do |row|
send_event('listofdata', { label: row['name'], value: row['value'] })
end
No matter what I seem to do, I can't get any data to show in the widget. Am I missing something incredibly obvious here?
Update 1: Tried also with this, didn't work:
datalist = results.each(:symbolize_keys => true, :as => :array, :cache_rows => true, :empty_sets => true) do |rowset| end
data_count = Array.new
for j in (0...results.affected_rows)
data_count << {"label" => datalist[j].at(0), "value" => datalist[j].at(1).to_i}
end