Merge 514a88e0be into a4ef10cf1b
This commit is contained in:
commit
f1e37df5a0
21 changed files with 264 additions and 3 deletions
|
|
@ -14,6 +14,7 @@ class EventSchedule < ActiveRecord::Base
|
|||
scope :confirmed, -> { joins(:event).where('state = ?', 'confirmed') }
|
||||
scope :canceled, -> { joins(:event).where('state = ?', 'canceled') }
|
||||
scope :withdrawn, -> { joins(:event).where('state = ?', 'withdrawn') }
|
||||
scope :current, -> { where('start_time <= ?', Time.current).select{ |es| es.end_time >= Time.current }}
|
||||
|
||||
delegate :guid, to: :room, prefix: true
|
||||
|
||||
|
|
|
|||
21
app/models/twitter_wrapper.rb
Normal file
21
app/models/twitter_wrapper.rb
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
class TwitterWrapper
|
||||
attr_accessor :client
|
||||
|
||||
def initialize
|
||||
@client = Twitter::REST::Client.new do |config|
|
||||
config.consumer_key = ENV['OSEM_TWITTER_CONSUMER_KEY']
|
||||
config.consumer_secret = ENV['OSEM_TWITTER_CONSUMER_SECRET']
|
||||
config.access_token = ENV['OSEM_TWITTER_ACCESS_TOKEN']
|
||||
config.access_token_secret = ENV['OSEM_TWITTER_ACCESS_TOKEN_SECRET']
|
||||
end
|
||||
end
|
||||
|
||||
##
|
||||
# Fetches tweets from twitter api based on search_term and no_of_tweets
|
||||
#
|
||||
def search_tweets(no_of_tweets, search_term)
|
||||
@client.search(search_term, result_type: 'recent').take(no_of_tweets).collect
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue