Skip to content

Commit

Permalink
populate subscription data for initial setup #23
Browse files Browse the repository at this point in the history
  • Loading branch information
kentwills committed Mar 18, 2017
1 parent a1e1e66 commit 1871688
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cron.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ cron:
url: /tasks/match_employees
schedule: every wednesday 11:00
timezone: US/Pacific

- description: Initialization (noop when subscriptions)
url: /tasks/init
schedule: every monday 11:00
timezone: US/Pacific
30 changes: 30 additions & 0 deletions yelp_beans/routes/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from __future__ import unicode_literals

import logging
from datetime import datetime

from flask import Blueprint

Expand All @@ -19,6 +20,8 @@
from yelp_beans.models import MeetingParticipant
from yelp_beans.models import MeetingRequest
from yelp_beans.models import MeetingSubscription
from yelp_beans.models import Rule
from yelp_beans.models import SubscriptionDateTime
from yelp_beans.send_email import send_batch_meeting_confirmation_email
from yelp_beans.send_email import send_batch_unmatched_email
from yelp_beans.send_email import send_batch_weekly_opt_in_email
Expand Down Expand Up @@ -92,3 +95,30 @@ def send_match_emails():
logging.info(matches)
send_batch_meeting_confirmation_email(matches, spec)
return "OK"


@tasks.route('/init', methods=['GET'])
def init():
subscriptions = MeetingSubscription.query().fetch()
if not subscriptions:
preference_1 = SubscriptionDateTime(
datetime=datetime.datetime.now()
).put()
preference_2 = SubscriptionDateTime(
datetime=datetime.datetime.now() + datetime.timedelta(days=1)
).put()
rule = Rule(
name='office',
value='USA: CA SF New Montgomery Office'
).put()

MeetingSubscription(
title='Yelp Weekly',
size=2,
location='8th Floor',
office='USA: CA SF New Montgomery Office',
timezone='US/Pacific',
datetime=[preference_1, preference_2],
rules=[rule],
rule_logic='any'
).put()

0 comments on commit 1871688

Please sign in to comment.