Skip to content
This repository has been archived by the owner on Jul 15, 2021. It is now read-only.

Commit

Permalink
Add rake task to update user Slack avatars
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierlacan committed Aug 11, 2017
1 parent 660ace3 commit e4f3dcd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 0 additions & 1 deletion app/models/slacker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def self.all
slack_user_data.map { |data| self.new(data) }
end


def self.find_by_email(email)
all.select { |m| m.email == email }.first
end
Expand Down
11 changes: 11 additions & 0 deletions lib/tasks/users.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
desc "Update Slack avatars"
task :update_slack_avatars => [:dependent, :tasks] do
users_with_broken_avatars = User.all.reject do |user|
Faraday.get(user.image).status == 200
end

users_with_broken_avatars.each do |user|
user.image = Slacker.find_by_id(user.slack_id).image
user.save
end
end

0 comments on commit e4f3dcd

Please sign in to comment.