summaryrefslogtreecommitdiff
path: root/templates/project/jobs
diff options
context:
space:
mode:
authorDaniel Beauchamp <daniel.beauchamp@shopify.com>2012-10-30 05:16:35 -0400
committerDaniel Beauchamp <daniel.beauchamp@shopify.com>2012-10-30 05:16:35 -0400
commita4a4564f760bb1bcd541366186cd46488d5a569b (patch)
tree3737ae6d233464482482880bd858665866686f10 /templates/project/jobs
parent3a77d19282f2055559c63468c574b824138464ac (diff)
Added new widgets, and made them more flexible. Ready for 0.1.3!
Diffstat (limited to 'templates/project/jobs')
-rw-r--r--templates/project/jobs/buzzwords.rb2
-rw-r--r--templates/project/jobs/convergence.rb1
-rw-r--r--templates/project/jobs/sample.rb4
-rw-r--r--templates/project/jobs/twitter.rb17
4 files changed, 23 insertions, 1 deletions
diff --git a/templates/project/jobs/buzzwords.rb b/templates/project/jobs/buzzwords.rb
index 109dc60..2668d5a 100644
--- a/templates/project/jobs/buzzwords.rb
+++ b/templates/project/jobs/buzzwords.rb
@@ -3,7 +3,7 @@ buzzword_counts = Hash.new({ value: 0 })
SCHEDULER.every '2s' do
random_buzzword = buzzwords.sample
- buzzword_counts[random_buzzword] = { label: random_buzzword, value: buzzword_counts[random_buzzword][:value] + 1 }
+ buzzword_counts[random_buzzword] = { label: random_buzzword, value: (buzzword_counts[random_buzzword][:value] + 1) % 30 }
send_event('buzzwords', { items: buzzword_counts.values })
end \ No newline at end of file
diff --git a/templates/project/jobs/convergence.rb b/templates/project/jobs/convergence.rb
index f66b6a5..1da2a5b 100644
--- a/templates/project/jobs/convergence.rb
+++ b/templates/project/jobs/convergence.rb
@@ -1,3 +1,4 @@
+# Populate the graph with some random points
points = []
(1..10).each do |i|
points << { x: i, y: rand(50) }
diff --git a/templates/project/jobs/sample.rb b/templates/project/jobs/sample.rb
index 2314dc2..1fe008d 100644
--- a/templates/project/jobs/sample.rb
+++ b/templates/project/jobs/sample.rb
@@ -1,9 +1,13 @@
current_valuation = 0
+current_karma = 0
SCHEDULER.every '2s' do
last_valuation = current_valuation
+ last_karma = current_karma
current_valuation = rand(100)
+ current_karma = rand(200000)
send_event('valuation', { current: current_valuation, last: last_valuation })
+ send_event('karma', { current: current_karma, last: last_karma })
send_event('synergy', { value: rand(100) })
end \ No newline at end of file
diff --git a/templates/project/jobs/twitter.rb b/templates/project/jobs/twitter.rb
new file mode 100644
index 0000000..9359a89
--- /dev/null
+++ b/templates/project/jobs/twitter.rb
@@ -0,0 +1,17 @@
+require 'net/http'
+require 'json'
+
+search_term = URI::encode('#todayilearned')
+
+SCHEDULER.every '10m', :first_in => 0 do |job|
+ http = Net::HTTP.new('search.twitter.com')
+ response = http.request(Net::HTTP::Get.new("/search.json?q=#{search_term}"))
+ tweets = JSON.parse(response.body)["results"]
+ if tweets
+ tweets.map! do |tweet|
+ { name: tweet['from_user'], body: tweet['text'], avatar: tweet['profile_image_url_https'] }
+ end
+
+ send_event('twitter_mentions', comments: tweets)
+ end
+end \ No newline at end of file