I have a Scheduler job that pulls some data from an external source and then sends it to the widget. How can I force that job to run whenever the page is refreshed? The contents don't change that frequently so I only want the job to run daily however whenever someone loads the dashboard for the first time I would like for it to load the contents. Here is my code:
Scheduler Job
require 'json'
require './lib/githubcomments'
comments = GithubComments.new
SCHEDULER.every '1d', :first_in => 0 do |job|
points = [name: "Operations", data: [comments.january.count,comments.february.count,comments.march.count,comments.april.count,comments.may.count,comments.june.count,comments.july.count,comments.august.count,comments.september.count,comments.october.count,comments.november.count,comments.december.count]]
x_axis = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]
y_axis_text = "Num of Comments"
send_event('code_comments', {series: points, x_axis: x_axis, y_axis: y_axis_text})
end
Widget
class Dashing.Highchart extends Dashing.Widget
createChart: (series,x_axis,y_axis) ->
@Chart = new Highcharts.Chart
chart:
renderTo: "HCcontainer"
type: "line"
series: series
xAxis: {
categories: x_axis
}
yAxis: {
title: {
text: y_axis
}
}
plotOptions: {
line: {
dataLabels: {
enabled: true
}
}
}
ready: ->
series = []
x_axis = []
y_axis = ""
@createChart(series,x_axis,y_axis)
onData: (data) ->
@createChart(data.series,data.x_axis,data.y_axis)