Skip to content

Instantly share code, notes, and snippets.

@mrobers1982
Created June 27, 2012 20:58
Show Gist options
  • Save mrobers1982/ac349456c68226263295 to your computer and use it in GitHub Desktop.
Save mrobers1982/ac349456c68226263295 to your computer and use it in GitHub Desktop.
FSD - remove first/last name data fix
import time, datetime
def reset_name(domain):
counter = 0
throttle = 0.07
start_time = datetime.datetime.now()
while(True):
users = UserProfile.objects.filter(domain=d).exclude(first_name=None, last_name=None)[:10000]
if len(users) == 0:
break
for u in users:
print "Removing first/last name for user: %s" % (u.jid)
u.first_name = None
u.last_name = None
u.save()
counter += 1
if counter % 10 == 0:
time.sleep(throttle)
end_time = datetime.datetime.now()
print 'Duration: %s' % str(end_time - start_time)
d = Domain.objects.get(id=136)
reset_name(d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment