-
Notifications
You must be signed in to change notification settings - Fork 909
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add stupid script to bulk check the gravatar status
- Loading branch information
1 parent
90b7101
commit ad0e7b2
Showing
1 changed file
with
17 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env ruby | ||
|
||
# require File.dirname(__FILE__) + "/../config/environment" | ||
|
||
start = 0 | ||
User.where("image_use_gravatar AND id >=" + start.to_s).order("id").find_each do |user| | ||
p "checked up to id " + user.id.to_s if user.id % 1000 == 0 # just give a rough indication where we are for restarting | ||
next if user.image.present? | ||
hash = Digest::MD5.hexdigest(user.email.downcase) | ||
url = "https://www.gravatar.com/avatar/#{hash}?d=404" # without d=404 we will always get an image back | ||
response = OSM.http_client.get(URI.parse(url)) | ||
user.image_use_gravatar = response.success? | ||
user.save | ||
sleep(1) | ||
end | ||
|
||
exit 0 |