daily pastebin goal
59%
SHARE
TWEET

Untitled

a guest Feb 23rd, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. university = Site.find(ENV["UNIVERSITY_SITE_ID"])
  2.     members = university.members
  3.     count = 0
  4.     member_emails = []
  5.     emails_as_eui_count = 0
  6.    
  7.     # find emails as external user ids
  8.     members.find_each do |member|
  9.       eui = member.external_user_id
  10.       if eui && eui.include?("@")
  11.           emails_as_eui_count += 1
  12.       end
  13.     end
  14.  
  15.     # finds mismatched university member external_user_ids
  16.     # from their KJB user account id
  17.     members.find_each do |member|
  18.       email = member.email
  19.       eui   = member.external_user_id
  20.  
  21.       if eui && !eui.include?("@")
  22.         id = eui.split(":")[-1]
  23.  
  24.         if u = User.find_by(id: id)
  25.           unless u.email == email
  26.             puts "Mismatch! member_id: #{member.id}, email: #{email}, eui: #{eui}"
  27.             member_emails << email
  28.             count +=1
  29.           end
  30.         end
  31.       end
  32.     end
  33.  
  34.     puts "count: #{count}"
  35.  
  36.  
  37.     university_users_count = User.where(email: member_emails).count
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top