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-7.12.0 lib/tasks/assignments.rake
mumuki-laboratory-7.11.1 lib/tasks/assignments.rake
mumuki-laboratory-7.11.0 lib/tasks/assignments.rake
mumuki-laboratory-7.10.5 lib/tasks/assignments.rake
mumuki-laboratory-7.10.4 lib/tasks/assignments.rake
mumuki-laboratory-7.10.3 lib/tasks/assignments.rake
mumuki-laboratory-7.10.2 lib/tasks/assignments.rake
mumuki-laboratory-7.10.1 lib/tasks/assignments.rake
mumuki-laboratory-7.10.0 lib/tasks/assignments.rake
mumuki-laboratory-7.9.2 lib/tasks/assignments.rake
mumuki-laboratory-7.9.1 lib/tasks/assignments.rake
mumuki-laboratory-7.9.0 lib/tasks/assignments.rake
mumuki-laboratory-7.7.6 lib/tasks/assignments.rake
mumuki-laboratory-7.7.5 lib/tasks/assignments.rake
mumuki-laboratory-7.7.4 lib/tasks/assignments.rake
mumuki-laboratory-7.8.0 lib/tasks/assignments.rake
mumuki-laboratory-7.7.3 lib/tasks/assignments.rake
mumuki-laboratory-7.7.2 lib/tasks/assignments.rake
mumuki-laboratory-7.7.1 lib/tasks/assignments.rake
mumuki-laboratory-7.7.0 lib/tasks/assignments.rake