FogBugz #135: completed controller methods in preparation of sending birthday mails only in 7 days + 2 days in advance.
This commit is contained in:
parent
cf32952cd1
commit
60f1368c1e
1 changed files with 14 additions and 1 deletions
|
|
@ -3,7 +3,7 @@ class BirthdaysController < ApplicationController
|
|||
before_filter :authenticate_user!, :except => [:do_mailing]
|
||||
|
||||
def index
|
||||
@birthdays = get_birthdays_next_7d
|
||||
@birthdays = get_birthdays_in_2d # get_birthdays_next_7d
|
||||
@nav_active = "birthdays"
|
||||
end
|
||||
|
||||
|
|
@ -45,6 +45,14 @@ class BirthdaysController < ApplicationController
|
|||
get_birthdays_next_n_days(2)
|
||||
end
|
||||
|
||||
def get_birthdays_in_7d
|
||||
get_birthdays_in_n_days(7)
|
||||
end
|
||||
|
||||
def get_birthdays_in_2d
|
||||
get_birthdays_in_n_days(2)
|
||||
end
|
||||
|
||||
def get_birthdays_next_n_days(num_days)
|
||||
n = Date.today
|
||||
e = Date.today + num_days.days
|
||||
|
|
@ -60,6 +68,11 @@ class BirthdaysController < ApplicationController
|
|||
birthdays
|
||||
end
|
||||
|
||||
def get_birthdays_in_n_days(num_days)
|
||||
target_date = Date.today + num_days.days
|
||||
birthdays = Contact.where("birth_month = ? AND birth_day = ?", target_date.month, target_date.day)
|
||||
end
|
||||
|
||||
# in: Array [contact,contact,contact,...]
|
||||
# out: Hash[email] = [contact,contact,contact,....]
|
||||
def group_birthdays_by_email(birthday_contacts)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue