Created
July 5, 2012 23:02
-
-
Save conniec/3056989 to your computer and use it in GitHub Desktop.
disable gravatar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from lfcore.ident.api import IdentAPI | |
import time, datetime | |
def disable_gravatar(domain_name): | |
throttle = 0.07 | |
start_time = datetime.datetime.now() | |
d = Domain.objects.get(name=domain_name) | |
a = 0 | |
b = 10000 | |
while(True): | |
all_users = UserProfile.objects.filter(domain=d, state=RowState.enums().ENABLED)[a:b] | |
if len(all_users) == 0: | |
break | |
data = { | |
"gravatar_disabled": True | |
} | |
for (counter, user) in enumerate(all_users): | |
if counter % 20 == 0: | |
time.sleep(throttle) | |
if not user.gravatar_disabled: | |
IdentAPI.update_remote_profile(user, data) | |
print "User: %d - %s" % (user.id, user.gravatar_disabled) | |
a = b | |
b = b + 10000 | |
end_time = datetime.datetime.now() | |
print 'Duration: %s' % str(end_time - start_time) | |
disable_gravatar('rooms.speedtv.fyre.co') #90220 users | |
disable_gravatar('rooms.foxsports.fyre.co') #50240 users |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For SpeedTV, we need to grab the users in chunks. Here is an example - https://gist.github.com/ac349456c68226263295