is fired when the widget is done being rendered onData: (data) -> # Fired when you receive data # You could do something like have the widget flash each time data comes in by doing: # $(@node).fadeOut().fadeIn() # Any attribute that has the 'Dashing.AnimatedValue' will cause the number to animate when it changes. @accessor 'current', Dashing.AnimatedValue # Calculates the % difference between current & last values. @accessor 'difference', -> if @get('last') last = parseInt(@get('last')) current = parseInt(@get('current')) if last != 0 diff = Math.abs(Math.round((current - last) / last * 100)) "#{diff}%" else "" # Picks the direction of the arrow based on whether the current value is higher or lower than the last @accessor 'arrow', -> if @get('last') if parseInt(@get('current')) > parseInt(@get('last')) then 'icon-arrow-up' else 'icon-arrow-down' number.coffee
send_event('karma', { current: rand(1000) }) end sample_job.rb This job will run every minute, and will send a random number to ALL widgets that have data-id set to 'karma'.
client = Octokit::Client.new(:login => "login", :password => "password") %w[churchmetrics open chop develop-dot-me].each do |repo| current = client.pull_requests("lifechurch/#{repo}").size send_event("#{repo}_pull_requests", current: current) end end
SCHEDULER.every ‘3m' do |job| projects.each do |name, repo| response = HTTParty.get("https://codeclimate.com/api/repos/#{repo}", body: {api_token: API_TOKEN} ) data = { current: response[:last_snapshot]["gpa"].to_s, last: (response[:previous_snapshot]["gpa"].to_s rescue "---") } send_event("codeclimate_#{name}", data ) end end