Skip to content
This repository has been archived by the owner on Aug 6, 2023. It is now read-only.

Commit

Permalink
dynamic_follow_list added
Browse files Browse the repository at this point in the history
  • Loading branch information
cmirnow committed Aug 19, 2021
1 parent 903b3cd commit 56cb519
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
6 changes: 0 additions & 6 deletions app/jobs/application_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ def unfollow(tweet)
array[1] - array[0]
end

def save_follow_list(*args)
CSV.open("#{Rails.root}/follow_lists/" + args[1] + ".csv", 'w') do |csv|
csv << args[0].map { |e| e.id }
end
end

def get_user_lists(tweet)
[GetFollowersJob.perform_now(tweet), GetFriendsJob.perform_now(tweet)]
end
Expand Down
18 changes: 18 additions & 0 deletions app/jobs/follow_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def perform(*args)
list.take(100).each do |user|
client.follow(user.id)
list.delete(user)
dynamic_follow_list(args[1])
puts "follow: #{user.screen_name} #{Time.now}"
sleep rand(30..60)
end
Expand All @@ -22,4 +23,21 @@ def perform(*args)
retry
end
end

def dynamic_follow_list(nick)
array_of_ids = CSV.open(path_to_csv_file(nick)).to_a.flatten.drop(1)
CSV.open(path_to_csv_file(nick), 'w') do |csv|
csv << array_of_ids
end
end

def save_follow_list(*args)
CSV.open(path_to_csv_file(args[1]), 'w') do |csv|
csv << args[0].map { |e| e.id }
end
end

def path_to_csv_file(nick)
"#{Rails.root}/follow_lists/" + nick + '.csv'
end
end

0 comments on commit 56cb519

Please sign in to comment.