Skip to content

Instantly share code, notes, and snippets.

@RonBarabash
Last active August 29, 2015 14:22
Show Gist options
  • Save RonBarabash/2ab724af3b11c1cd3b41 to your computer and use it in GitHub Desktop.
Save RonBarabash/2ab724af3b11c1cd3b41 to your computer and use it in GitHub Desktop.
Here are some things you can do with Gists in GistBox.
integrations_conf = YAML.load_file("#{Rails.root}/config/integrations.yml")['production’]
Restforce.configure do |config|
config.username = integrations_conf['SALESFORCE']['USERNAME']
config.password = integrations_conf['SALESFORCE']['PASSWORD']
config.security_token = integrations_conf['SALESFORCE']['TOKEN']
config.client_id = integrations_conf['SALESFORCE']['CLIENT_ID']
config.client_secret = integrations_conf['SALESFORCE']['CLIENT_SECRET']
config.host = integrations_conf['SALESFORCE']['HOST'] if integrations_conf['SALESFORCE']['HOST'].present?a
end
client = Restforce.new
client.authenticate!
stores = client.query("SELECT Account.User_ID__c, (SELECT Account_ID__c FROM Yotpo_Stores__r) FROM Account WHERE num_of_Yotpo_Stores__c > 1 “)
parsed_data = stores.map{|store| {:user_id => store.User_ID__c,:stores => store.Yotpo_Stores__r.map(&:Account_ID__c)}}
parsed_data.map {|d| size = App.where(account_id: d[:stores] ).group(:user_id).size
a.push(size) if size.present? && size.size > 1
}
a.reject(&:blank?)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment