Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # TODO scope to company
- def remove_duplicate_outcomes(outcome_name)
- outcomes = Outcome.where(name: outcome_name)
- if outcomes.length > 1
- puts outcome_name
- true_t = outcomes[0]
- false_ts = outcomes[1..outcomes.length]
- false_ts.each do |false_t|
- qry = "outcome_ids @> ARRAY[#{false_t.id}]"
- calls = Call.where(qry)
- calls.each do |call|
- o_ids = call.outcome_ids.map { |x| x == false_t.id ? true_t.id : x }
- call.outcome_ids = o_ids
- call.save
- end
- puts Call.where(qry).count
- false_t.delete
- end
- end
- end
- def remove_duplicate_tags(tag_name)
- tags = Tag.where(name: tag_name)
- if tags.length > 1
- puts tag_name
- true_t = tags[0]
- false_ts = tags[1..tags.length]
- false_ts.each do |false_t|
- Call.where(tag_id: false_t.id).update_all(tag_id: true_t.id)
- puts Call.where(tag_id: false_t.id).count
- false_t.delete
- end
- end
- end
- def migrate_ct(ct, new_ct)
- puts "#{ct.name} --> #{new_ct.name}"
- # calls
- calls = Call.where(call_type_id: ct.id)
- calls.update_all(call_type_id: new_ct.id)
- # outcomes
- outcomes = Outcome.where(call_type_id: ct.id)
- outcomes.update_all(call_type_id: new_ct.id)
- # tags
- tags = Tag.where(call_type_id: ct.id)
- tags.update_all(call_type_id: new_ct.id)
- # qar
- qars = QaRecord.where(call_type_id: ct.id)
- qars.update_all(call_type_id: new_ct.id)
- # ct skills
- ct_skills = PermittedCallTypeSkill.where(call_type_id: ct.id)
- ct_skills.each do |ct_skill|
- begin
- PermittedCallTypeSkill.create(call_type_id: new_ct.id,
- skill_id: ct_skill.skill_id)
- rescue
- end
- end
- # ct_skills.destroy_all
- # ct user
- ct_users = CallTypeUserMembership.where(call_type_id: ct.id)
- ct_users.each do |ct_user|
- CallTypeUserMembership.create(call_type_id: new_ct.id,
- user_id: ct_user.user_id)
- end
- # ct_users.destroy_all
- # ct.delete
- end
- # WEEBLY ================================================
- weebly = Company.find_by(name: "weebly")
- puts weebly.name
- # inbound ==========================================
- dark_side = Team.find_by(name: "Dark Side") || Team.create(name: "Dark Side",
- company_id: weebly.id)
- jedi_knights = Team.find_by(name: "Jedi Knights") || Team.create(name: "Jedi Knights",
- company_id: weebly.id)
- rogue = Team.find_by(name: "Rogue") || Team.create(name: "Rogue",
- company_id: weebly.id)
- inbound_reps = [
- ["Alex", "Neuendorf", jedi_knights.id],
- ["Ari", "Lamos", dark_side.id],
- ["Bri", "Hendrickson", dark_side.id],
- ["Charles", "Robinson", jedi_knights.id],
- ["Chris", "Cottle", dark_side.id],
- ["Christopher", "Warmuth", dark_side.id],
- ["Colin", "Jacobs", dark_side.id],
- ["Dory", "Edwards", dark_side.id],
- ["Emmanuel", "Tunrarebi", dark_side.id],
- ["Erika", "Keller", jedi_knights.id],
- ["Gen", "Burgos", jedi_knights.id],
- ["Herlinda", "Ayala", jedi_knights.id],
- ["Jacob", "Cory", jedi_knights.id],
- ["Janelle", "Jackson", jedi_knights.id],
- ["Jasen", "Tittes", dark_side.id],
- ["Jason", "Pyle", dark_side.id],
- ["Jenn", "Simmons", jedi_knights.id],
- ["Jessie", "Marquez", jedi_knights.id],
- ["Jessie", "Zuppello", jedi_knights.id],
- ["Josh", "Finger", jedi_knights.id],
- ["Mary", "Harrison", dark_side.id],
- ["Michael", "Corrigan", dark_side.id],
- ["Nathan", "Milas", dark_side.id],
- ["Nicole", "Johnson", jedi_knights.id],
- ["Nina", "Sadek", jedi_knights.id],
- ["Paul", "Fairbrother", dark_side.id],
- ["Rachel", "Green", dark_side.id],
- ["Reed", "Daniel", jedi_knights.id],
- ["Ryan", "Avery", dark_side.id],
- ["Samuel", "Spencer", jedi_knights.id],
- ["Selma", "Nguyen", jedi_knights.id],
- ["Spencer", "Morrell", jedi_knights.id],
- ["Steve", "Sparks", dark_side.id],
- ["Taylor", "Smetska", dark_side.id],
- ["Tiffany", "Smith", dark_side.id],
- ["Vas", "Annos", dark_side.id],
- ["Waylon", "Wood", jedi_knights.id],
- ["William", "Sams III", dark_side.id],
- ["Zachary", "Gemmill", jedi_knights.id]
- ]
- inbound_reps.each do |first, last, team_id|
- u = User.find_by(first_name: first, last_name: last)
- u.team_id = team_id
- u.save
- end
- derek = User.find_by(first_name: "Derek", last_name: "Mulch")
- derek.team_id = rogue.id
- derek.save
- chris = User.find_by(first_name: "Christopher", last_name: "Krivosik")
- chris.team_id = rogue.id
- chris.save
- martin = User.find_by(first_name: "Martin", last_name: "Guerrero")
- martin.team_id = rogue.id
- martin.save
- bernie = User.find_by(first_name: "Bernadette", last_name: "Zavala")
- bernie.team_id = rogue.id
- bernie.save
- # inbound ==========================================
- # outbound ==========================================
- boba_fett = Team.find_by(name: "Boba Fett") || Team.create(name: "Boba Fett",
- company_id: weebly.id)
- outbound_reps = [
- ["Nicholas", "Perry"],
- ["Ashley", "Klein"],
- ["Brodie", "Hubbard"],
- ["Nicholas", "Perry"],
- ["Andrew", "Daniele"],
- ["Adam", "Nieland"],
- ["Corey", "Noll"],
- ["Rick", "Morse"],
- ["Matt", "Macaluso"],
- ["Kameron", "Toll"],
- ["Dan", "Rivkin"],
- ["Tim", "Thompson"]
- ]
- outbound_reps.each do |first, last|
- u = User.find_by(first_name: first, last_name: last)
- u.team_id = boba_fett.id
- u.save
- end
- nick_p = User.find_by(email: "nick.p@weebly.com")
- nick_p.team_id = boba_fett.id
- nick_p.save
- # outbound ==========================================
- # chat ==========================================
- # chat ==========================================
- # team-ct ==========================================
- teams = [rogue, dark_side, jedi_knights, boba_fett]
- teams.each do |team|
- user_ids = User.where(team_id: team.id).pluck(:id)
- ctids = Call.where(user_id: user_ids).pluck(:call_type_id).uniq
- ctids.each do |ctid|
- TeamCallType.create(call_type_id: ctid, team_id: team.id)
- end
- end
- # team-ct ==========================================
- weebly.call_types.reverse.each do |ct|
- team = Team.find_by(name: ct.name, company_id: ct.company_id)
- next if !team
- ct_users = User.where(team_id: team.id).pluck(:first_name, :last_name, :email, :id)
- next if ct_users.count == 0
- puts "#{ct.id} #{ct.name} -- #{ct_users.count}"
- # ct_users.each do |f, l, e, id|
- # puts "#{f} #{l}: #{e}"
- # end
- end
- # managers ==========================================
- # JEDI
- keri = User.find_by(first_name: "Keri", last_name: "Young-Koppendrayer")
- keri.team_id = jedi_knights.id
- keri.save
- # BOBA FETT
- julian = User.find_by(email: "julian.a@weebly.com")
- julian.team_id = boba_fett.id
- julian.save
- # CHAT TODO
- chat = Team.find_by(name: "chat")
- william = User.find_by(email: "william.b@weebly.com")
- william.team_id = chat.id
- william.save
- david = User.find_by(first_name: "David", last_name: "Medansky")
- david.team_id = rogue.id
- david.save
- # Inbound/Outbound Manager Matthew Jenks matthew.j@weebly.com
- # TODO
- # Director Aaron McElroy aaronm@weebly.com
- # Director Adam Lovill adam.l@weebly.com
- # Director Alan Chambless alan@weebly.com
- # managers ==========================================
- # WEEBLY ================================================
- # ICE ================================================
- ice = Company.find_by(id: 49)
- puts ice.name
- subscription = CallType.find_by(name: "subscription", company_id: ice.id) ||
- CallType.create(name: "subscription", company_id: ice.id, daily_alert_threshold: 12)
- heavy_hitters = Team.find_by(name: "The Heavy Hitters", company_id: ice.id)
- money_makers = Team.find_by(name: "Mad Money Makers", company_id: ice.id)
- cts = CallType.where(company_id: ice.id).where.not(id: subscription.id)
- cts.each do |ct|
- migrate_ct(ct, subscription)
- end
- # team ct
- teams = [heavy_hitters, money_makers]
- teams.each do |team|
- users = User.where(team_id: team.id).pluck(:id)
- ctids = Call.where(user_id: users).pluck(:call_type_id).uniq
- ctids.each do |ctid|
- TeamCallType.create(call_type_id: ctid, team_id: team.id)
- end
- end
- # remove duplicate outcomes and tags
- tag_names = Tag.where(call_type_id: subscription).pluck(:name).uniq
- outcome_names = Outcome.where(call_type_id: subscription).pluck(:name).uniq
- tag_names.each do |tag_name|
- remove_duplicate_tags(tag_name)
- end
- outcome_names.each do |outcome_name|
- remove_duplicate_outcomes(outcome_name)
- end
- # ICE ================================================
- # SITELOCK ================================================
- sitelock = Company.find(47)
- puts sitelock.name
- cts = CallType.where(company_id: sitelock.id)
- inbound = CallType.find_by(company_id: sitelock.id, name: "Inbound")
- outbound = CallType.find_by(company_id: sitelock.id, name: "Outbound")
- retention = CallType.find_by(company_id: sitelock.id, name: "Retention")
- begin
- PermittedCallTypeSkill.create(call_type_id: outbound.id, skill_id: 45)
- PermittedCallTypeSkill.create(call_type_id: outbound.id, skill_id: 53)
- PermittedCallTypeSkill.create(call_type_id: inbound.id, skill_id: 45)
- rescue
- end
- cts = [
- ["LXG", outbound.id],
- ["CAPTCHA Amerika", outbound.id],
- ["Commission Possible", outbound.id],
- ["Big Bots", outbound.id],
- ["Retention", retention.id],
- ["Brute Force", inbound.id],
- ["High Rollers", inbound.id],
- ["Nights", inbound.id]
- ]
- cts.each do |ct_name, new_ct_id|
- ct = CallType.find_by(name: ct_name, company_id: sitelock.id)
- new_ct = CallType.find(new_ct_id)
- migrate_ct(ct, new_ct)
- end
- # managers
- man_emails = [
- ["einfante@sitelock.com", "LXG"],
- ["isaac.doss@sitelock.com", "LXG"],
- ["erichardson@sitelock.com", "Brute Force"],
- ["tracee.patterson@sitelock.com", "Brute Force"],
- ["daniel.jones@sitelock.com", "High Rollers"],
- ["jeremy.hibler@sitelock.com", "Nights"],
- ["nfraccola@sitelock.com", "Big Bots"],
- ["jzuppello@sitelock.com", "Big Bots"],
- ["erik.reed@sitelock.com", "CAPTCHA Amerika"],
- ["rstone@sitelock.com", "CAPTCHA Amerika"],
- ["duncan.macdonald@sitelock.com", "Commission Possible"],
- ["colleen.wagner@sitelock.com", "Commission Possible"],
- ["bmartin@sitelock.com", "Retention"]
- ]
- dir_emails = [
- ["ahale@sitelock.com", ["Big Bots",
- "CAPTCHA Amerika",
- "LXG",
- "Commission Possible",
- "Retention"]],
- ["dcoons@sitelock.com", ["Brute Force",
- "High Rollers",
- "Nights"]]
- ]
- man_emails.each do |email, team_name|
- u = User.find_by(email: email)
- team = Team.find_by(name: team_name, company_id: sitelock.id)
- u.team_id = team.id
- u.save
- end
- dir_emails.each do |email, t_names|
- puts email
- u = User.find_by(email: email)
- teams = Team.where(name: t_names, company_id: sitelock.id).pluck(:id)
- u.directed_team_ids = teams
- u.save
- end
- # SITELOCK ================================================
Add Comment
Please, Sign In to add comment