Closed amallah closed 8 years ago
This is the function: https://github.com/dphuang2/PoGoBag/blob/master/app/helpers/sessions_helper.rb
def refresh_data(user)
auth_objects = authorized_client(user.refresh_token, 'refresh_token')
client = auth_objects[:client]
user = setup_client_user_pair(client, user.refresh_token)
store_data(client, user)
end
Before it was being done automatically through crontabs by checking if the saved refresh token can still be used and then running refresh_data: https://github.com/dphuang2/PoGoBag/blob/master/lib/tasks/refresh_data.rake
desc 'update all user data with google accounts'
task refresh_data: :environment do
include SessionsHelper
Poke::API::Logging.log_level = :WARN if Rails.env.production?
Rails.logger.warn "Running rake task"
@users = User.where.not('refresh_token' => nil)
@users.each do |user|
if user.access_token_expire_time > Time.now.to_i
refresh_data(user)
end
end
end
What is the method to force a refresh of server data from local?