Sha256: 5cbaafc71aa9330df00c9599d7b570a76ab2d1dcaaf77a5ef0c0e4597bfba10c

Contents?: true

Size: 1.1 KB

Versions: 119

Compression:

Stored size: 1.1 KB

Contents

namespace :laboratory do
  namespace :assignments do
    task :notify_all, [:organization_name, :date_since] => :select_organization do |t, args|
      args.with_defaults(date_since: '2014-01-01')
      Organization.current.notify_recent_assignments! Date.parse(args[:date_since])
    end

    task :notify_user, [:organization_name, :user_uid] => :select_organization do |t, args|
      user = User.find_by(uid: args[:user_uid])
      puts "Found user #{user.name}."

      Organization.current.notify_assignments_by! user
    end

    task :notify_recent, [:organization_name] => :select_organization do |t, args|
      Organization
        .current
        .assignments
        .where(submitter: User.where(last_organization: Organization.current))
        .where('assignments.created_at > ?', 1.month.ago)
        .each(&:notify!)
    end

    # This task should not be called directly (because it "does nothing"), it's just a prerrequisite for the others.
    task :select_organization, [:organization_name] => :environment do |t, args|
      Organization.find_by!(name: args[:organization_name]).switch!
    end
  end
end

Version data entries

119 entries across 119 versions & 1 rubygems

Version Path
mumuki-laboratory-9.23.0 lib/tasks/assignments.rake
mumuki-laboratory-9.22.0 lib/tasks/assignments.rake
mumuki-laboratory-9.21.0 lib/tasks/assignments.rake
mumuki-laboratory-9.20.1 lib/tasks/assignments.rake
mumuki-laboratory-9.20.0 lib/tasks/assignments.rake
mumuki-laboratory-9.19.0 lib/tasks/assignments.rake
mumuki-laboratory-9.18.1 lib/tasks/assignments.rake
mumuki-laboratory-9.18.0 lib/tasks/assignments.rake
mumuki-laboratory-9.17.0 lib/tasks/assignments.rake
mumuki-laboratory-9.16.0 lib/tasks/assignments.rake
mumuki-laboratory-9.15.0 lib/tasks/assignments.rake
mumuki-laboratory-9.14.1 lib/tasks/assignments.rake
mumuki-laboratory-9.14.0 lib/tasks/assignments.rake
mumuki-laboratory-9.13.2 lib/tasks/assignments.rake
mumuki-laboratory-9.13.1 lib/tasks/assignments.rake
mumuki-laboratory-9.13.0 lib/tasks/assignments.rake
mumuki-laboratory-9.12.1 lib/tasks/assignments.rake
mumuki-laboratory-9.12.0 lib/tasks/assignments.rake
mumuki-laboratory-9.11.0 lib/tasks/assignments.rake
mumuki-laboratory-9.10.0 lib/tasks/assignments.rake