Skip to content
This repository has been archived by the owner on Jul 19, 2020. It is now read-only.

Tweets appear immediately, Follower only after 2 minutes (first job execution) #14

Open
sesu85 opened this issue Mar 9, 2016 · 0 comments

Comments

@sesu85
Copy link

sesu85 commented Mar 9, 2016

Hi everyone,
if I execute my dashing with this widget, I always get the Tweets by loading the page immediately, but the Followers only after first execution of the job, so after 2 minutes.
I already tried to reorder the commands, but always with the same result.
Has anyone an idea?
Thank you,
Sebastian

twitter_username = ENV['TWITTER_USERNAME'] || 'BWweissenstadt'

SCHEDULER.every '2m', :first_in => 0 do |job|
  doc = Nokogiri::HTML(open("https://twitter.com/#{twitter_username}"))
  followers = doc.css('a[data-nav=followers]').first.attributes['title'].value.split(' ').first
  send_event('twitter', follower: followers)  
  tweets = doc.css('a[data-nav=tweets]').first.attributes['title'].value.split(' ').first
  tweets << " Tweets"
  send_event('twitter', tweet: tweets)
end
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant