
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_support/all' | |
require 'faraday' | |
require 'json' | |
AUTH_USERNAME = '' | |
AUTH_PASSWORD = '' | |
def fetch_pp_data(provider_id = 14, token_type = :account, day_epoch = Time.now.beginning_of_day.to_i) | |
pp_id = [provider_id, token_type, day_epoch].join(':') | |
url = "https://token-service.bmasked.info/v1/pool_projections/#{pp_id}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Queue jobs to sync/save AccountMeta records via SocialGraphService for every TopicUpdate. | |
# This is to prevent high latency on SocialGraphService due to inline provider scraping(takes long time), during API requests | |
# Note: set SOCIAL_GRAPH_SERVICE_URL | |
# Note: set X-SSL-Auth | |
ElasticsearchTopicUpdate.migrate(nil) do |batch| | |
bulk_args = batch.map { |es_topic_updates| ['TopicUpdate', :sync_account_meta, [es_topic_updates.account_guid]] } | |
Sidekiq::Client.new(SIDEKIQ_TOPIC_REDIS).push_bulk('class' => MigrationWorker, 'args' => bulk_args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Given mongoid Account model | |
class Account | |
include Mongoid::Document | |
field encrypted_token | |
field token_version | |
attr_encryptor :token, key: proc { |account| ENV["ACCOUNT_TOKEN_ENCRYPTION_KEY_V#{account.token_version}"] }, encode: true | |
end |