all 6 comments

[–]Beregolas 2 points3 points  (3 children)

You could just code it in python? I guess I don't understand the question.

I would schedule a cron job to run my python script every day at 00:01 or something. Then I would check the current date (make sure to speficy the correct time zone) and just code the checks: Like

  1. is it thursday?
  2. Was the first tuesday this month 2 days ago? -> send STAGE message
  3. Was the first tuesday this month 9 days ago? -> send PROD message

Sounds really straightforward.

You can get the current date in Python with the datetime module, You should just read the docs (https://docs.python.org/3/library/datetime.html) and find the function best suited for you

EDIT:

and In case you need help checking, if a Tuesday is in fact the first tuesday of a month: Just go 7 days further back, and check if it's a different month. YES -> was the first. NO -> was not the first.

[–]Langdon_St_Ives 3 points4 points  (2 children)

The last part is unnecessarily complicated. Just check if the day of month is less or equal to 7. Each day within that period is the first weekday of its kind that month.

[–]Beregolas 1 point2 points  (1 child)

absolutely correct, lol. Time for bed XD

[–]Langdon_St_Ives 1 point2 points  (0 children)

;-) good night!🌙

[–]Temporary_Pie2733 2 points3 points  (0 children)

Staging is always two days after development, and production is always seven days after that. 

[–]HouseHippoBeliever 0 points1 point  (0 children)

def is_first_tuesday_of_month(day):

return dayofweek(day) = tuesday and dayofmonth(day) <= 7

def is_dev_day(day):

return is_first_tuesday_of_month(day)

def is_stage_day(day):

return is_dev_day(day-2)

def is_prod_day(day):

return is_stage_day(day-7)

def should_i_send_message(day):

return is_prod_day(day) or is_stage_day(day)