Class: AllocationPreset

Inherits:
VRCron
  • Object
show all
Defined in:
crons/allocation_preset.rb

Overview

Create auto-set allocation for all Users marked as using the allocation system.

Cron Job:

Class Method Summary (collapse)

Methods inherited from VRCron

#cron, cronjobs, each, vrcron_name, vrcron_schedule, vrcron_type

Class Method Details

+ (Boolean) cron

Method invoked when called by the Scheduler job

Returns:

  • (Boolean)

    Return is a pass-through of presetAll - True on success, False otherwise



24
25
26
# File 'crons/allocation_preset.rb', line 24

def self.cron()
	return presetAll()
end

+ (Boolean) presetAll

Create a MonthlyAllocation for all Users who had an allocation in the prior month. Preset will be the same as the previous month and marked as an auto allocation.

Returns:

  • (Boolean)

    True on success, False otherwise



32
33
34
35
36
37
38
39
40
41
# File 'crons/allocation_preset.rb', line 32

def self.presetAll()
	users = User.all(:useAllocation => true, :active => true)
	
	users.each do |u|
		next if(u.lastAllocation.nil?)
		MonthlyAllocation.autoSetAllocationForUser(u.id, u.lastAllocation.allocation)
	end

	return true
end