Skip to content

Commit de9841c

Browse files
committed
Fetch access token each Rake task execution
1 parent 39b3fd5 commit de9841c

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,3 @@ script:
2020
env:
2121
global:
2222
- TZ='Asia/Tokyo'
23-
- FACEBOOK_ACCESS_TOKEN='dummy_token'

lib/statistics/client.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,10 @@ def fetch_events(group_id:, since_at: @default_since, until_at: @default_until)
111111
end
112112

113113
class Facebook
114+
class_attribute :access_token
115+
114116
def initialize
115-
@client = Koala::Facebook::API.new(ENV.fetch('FACEBOOK_ACCESS_TOKEN'))
117+
@client = Koala::Facebook::API.new(self.access_token)
116118
end
117119

118120
def fetch_events(group_id:, since_at: nil, until_at: nil)

lib/tasks/statistics.rake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ namespace :statistics do
3535
Time.current.prev_month.end_of_month
3636
end
3737

38+
Statistics::Client::Facebook.access_token = Koala::Facebook::OAuth.new(ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_APP_SECRET']).get_app_access_token
39+
3840
EventHistory.where(evented_at: from..to).delete_all
3941

4042
loop.with_object([from]) { |_, list|

0 commit comments

Comments
 (0)