Skip to content

Instantly share code, notes, and snippets.

@pecha7x
Created May 10, 2018 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pecha7x/7a2495abb1e5935fc23a1e434454b287 to your computer and use it in GitHub Desktop.
Save pecha7x/7a2495abb1e5935fc23a1e434454b287 to your computer and use it in GitHub Desktop.
memberships_to_statuses_analyze.rb
@client = Integrations::Mindbody.new company_id: company.id
person_without_plans = []
person_with_plans_with_nil_status = []
person_with_plans_with_other_status = []
membership_to_statuses = MindbodyMembershipsToStatuses.where(company_id: company.id)
company.people.where.not(mindbody_id: nil).each do |person|
memberships = @client.active_client_memberships(person.mindbody_id)
memberships.each do |membership|
map = membership_to_statuses.where(
MindbodyMembershipsToStatuses[:membership_name].lower.eq(membership[:name].downcase)
).first
if map.blank?
person_without_plans << { id: person.id, plan_name: membership[:name].downcase }
else
if map.status.nil?
person_with_plans_with_nil_status << { id: person.id, plan_name: membership[:name].downcase }
else
person_with_plans_with_other_status << { id: person.id, gs_plan_id: map.id } if person.status != map.status
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment