Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep track of users and jobs to be marked as expired. #80

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion lib/tasks/job_status.rake
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
namespace :job_status do
desc "Closing past due jobs..."
task :close => :environment do
people = Hash.new
Job.all.where.not(status: 1).each do |j|
if j.latest_start_date < (Date.today - 365)
if j.user_id == nil
j.update_column(:status, 1)
elsif j.latest_start_date < (Date.today - 365)
begin
poster = User.find(j.user_id)
if people[poster] == nil
people[poster] = Array.new
end
people[poster].push(j)
#j.update_column(:status, 1)
rescue
puts j.user_id
end
end
end
people.each do |k, v|
# Do Stuff with |User, [Jobs]|
v.each do |j|
# Do Stuff with |Jobs|
end
end
end
Expand All @@ -18,4 +36,15 @@ namespace :job_status do
end
end
end

desc "Checking How Many Old Jobs..."
task :count => :environment do
count = 0
Job.all.where.not(status: 1).each do |j|
if j.latest_start_date < (Date.today - 365)
count += 1
end
end
p count
end
end