ShelbyTV / shelby_gt

Rails API services for Shelby GT
2 stars 0 forks source link

update origin_network for all faux users #181

Closed spinosa closed 11 years ago

spinosa commented 11 years ago

slowly

Find, in batches, all users where faux == 1 and then run u.public_roll.update_attribute(:origin_network, u.authentications[0].provider)

This will fix the issue @matyus (and possibly others) have seen with the occasional faux user not showing up as such on the front end.

iceberg901 commented 11 years ago

@spinosa I don't think it will completely solve that problem. See #175

spinosa commented 11 years ago

Yes @iceberg901, this won't address the issues presented by #175. But for users that do return faux this will make sure their public roll has all the expected metadata.


(for my own reference) running this code:

to_skip = 6_700_000
User.sort(:_id.asc).where(:faux => 1).limit(500_000).skip(to_skip).find_each.each do |u|
  unless GT::UserManager.user_has_all_special_roll_ids?(u)
    puts "Fixing user w/o special rolls #{u.nickname} (#{u.id})"
    GT::UserManager.ensure_users_special_rolls(u, true)
  end
  if !u.public_roll.origin_network
    puts "Adding origin network for User(#{u.id}) / #{u.authentications[0].provider} / #{u.created_at}"
    u.public_roll.update_attribute(:origin_network, u.authentications[0].provider)
  end
end
spinosa commented 11 years ago

TODO: handle fucked up User case for the block above (with to_skip = 6_500_000): NoMethodError: undefined method 'origin_network' for nil:NilClass

spinosa commented 11 years ago

ran this for all users, have a code fix coming that should address it going forward.