예제 #1
0
파일: cron.py 프로젝트: timbury/kitsune
def process_exit_surveys():
    """Exit survey handling.

    * Collect new exit survey results.
    * Save results to our metrics table.
    * Add new emails collected to the exit survey.
    """

    _process_exit_survey_results()

    # Get the email addresses from two days ago and add them to the survey
    # campaign (skip this on stage).
    if settings.STAGE:
        # Only run this on prod, it doesn't need to be running multiple times
        # from different places.
        return

    startdate = date.today() - timedelta(days=2)
    enddate = date.today() - timedelta(days=1)

    for survey in SURVEYS.keys():
        if 'email_collection_survey_id' not in SURVEYS[survey]:
            # Some surveys don't have email collection on the site
            # (the askers survey, for example).
            continue

        emails = get_email_addresses(survey, startdate, enddate)
        for email in emails:
            add_email_to_campaign(survey, email)

        statsd.gauge('survey.{0}'.format(survey), len(emails))
예제 #2
0
파일: cron.py 프로젝트: Anshdesire/kitsune
def process_exit_surveys():
    """Exit survey handling.

    * Collect new exit survey results.
    * Save results to our metrics table.
    * Add new emails collected to the exit survey.
    """

    _process_exit_survey_results()

    # Get the email addresses from two days ago and add them to the survey
    # campaign (skip this on stage).
    if settings.STAGE:
        # Only run this on prod, it doesn't need to be running multiple times
        # from different places.
        print ('Skipped email address processing in process_exit_surveys(). '
               'Set settings.STAGE to False to run it for real.')
        return

    startdate = date.today() - timedelta(days=2)
    enddate = date.today() - timedelta(days=1)

    for survey in SURVEYS.keys():
        emails = get_email_addresses(survey, startdate, enddate)
        for email in emails:
            add_email_to_campaign(survey, email)

        print '%s emails processed for %s...' % (len(emails), survey)
예제 #3
0
def process_exit_surveys():
    """Exit survey handling.

    * Collect new exit survey results.
    * Save results to our metrics table.
    * Add new emails collected to the exit survey.
    """

    _process_exit_survey_results()

    # Get the email addresses from 4-5 hours ago and add them to the survey
    # campaign (skip this on stage).

    # The cron associated with this process is set to run every hour,
    # with the intent of providing a 4-5 hour wait period between when a
    # visitor enters their email address and is then sent a follow-up
    # survey.
    # The range here is set between 4 and 8 hours to be sure no emails are
    # missed should a particular cron run be skipped (e.g. during a deployment)
    startdatetime = datetime.now() - timedelta(hours=8)
    enddatetime = datetime.now() - timedelta(hours=4)

    for survey in SURVEYS.keys():
        if not SURVEYS[survey][
                'active'] or 'email_collection_survey_id' not in SURVEYS[
                    survey]:
            # Some surveys don't have email collection on the site
            # (the askers survey, for example).
            continue

        emails = get_email_addresses(survey, startdatetime, enddatetime)
        for email in emails:
            add_email_to_campaign(survey, email)

        statsd.gauge('survey.{0}'.format(survey), len(emails))
예제 #4
0
def process_exit_surveys():
    """Exit survey handling.

    * Collect new exit survey results.
    * Save results to our metrics table.
    * Add new emails collected to the exit survey.
    """

    _process_exit_survey_results()

    # Get the email addresses from two days ago and add them to the survey
    # campaign (skip this on stage).
    if settings.STAGE:
        # Only run this on prod, it doesn't need to be running multiple times
        # from different places.
        print ('Skipped email address processing in process_exit_surveys(). '
               'Set settings.STAGE to False to run it for real.')
        return

    startdate = date.today() - timedelta(days=2)
    enddate = date.today() - timedelta(days=1)

    emails = get_email_addresses(startdate, enddate)
    for email in emails:
        add_email_to_campaign(email)

    print '%s emails processed...' % len(emails)
예제 #5
0
파일: cron.py 프로젝트: ChromiumEx/kitsune
def process_exit_surveys():
    """Exit survey handling.

    * Collect new exit survey results.
    * Save results to our metrics table.
    * Add new emails collected to the exit survey.
    """

    _process_exit_survey_results()

    # Get the email addresses from two days ago and add them to the survey
    # campaign (skip this on stage).
    if settings.STAGE:
        # Only run this on prod, it doesn't need to be running multiple times
        # from different places.
        return

    startdate = date.today() - timedelta(days=2)
    enddate = date.today() - timedelta(days=1)

    for survey in SURVEYS.keys():
        if 'email_collection_survey_id' not in SURVEYS[survey]:
            # Some surveys don't have email collection on the site
            # (the askers survey, for example).
            continue

        emails = get_email_addresses(survey, startdate, enddate)
        for email in emails:
            add_email_to_campaign(survey, email)

        statsd.gauge('survey.{0}'.format(survey), len(emails))
예제 #6
0
    def handle(self, **options):
        """
        * Collect new exit survey results.
        * Save results to our metrics table.
        * Add new emails collected to the exit survey.
        """

        utils._process_exit_survey_results()

        # Get the email addresses from 4-5 hours ago and add them to the survey
        # campaign (skip this on stage).

        # The cron associated with this process is set to run every hour,
        # with the intent of providing a 4-5 hour wait period between when a
        # visitor enters their email address and is then sent a follow-up
        # survey.
        # The range here is set between 4 and 8 hours to be sure no emails are
        # missed should a particular cron run be skipped (e.g. during a deployment)
        startdatetime = datetime.now() - timedelta(hours=8)
        enddatetime = datetime.now() - timedelta(hours=4)

        for survey in SURVEYS.keys():
            if (
                not SURVEYS[survey]["active"] or
                "email_collection_survey_id" not in SURVEYS[survey]
            ):
                # Some surveys don't have email collection on the site
                # (the askers survey, for example).
                continue

            emails = get_email_addresses(survey, startdatetime, enddatetime)
            for email in emails:
                add_email_to_campaign(survey, email)

            statsd.gauge("survey.{0}".format(survey), len(emails))
예제 #7
0
    def test_creds(self, mock_requests):
        """Ensure the token and secret are passed correctly."""
        with self.settings(SURVEYGIZMO_API_TOKEN='mytoken',
                           SURVEYGIZMO_API_TOKEN_SECRET='mysecret'):
            add_email_to_campaign('general', '*****@*****.**')

            url = mock_requests.put.call_args[0][0]
            ok_('api_token=mytoken' in url)
            ok_('api_token_secret=mysecret' in url)
예제 #8
0
    def test_creds(self, mock_requests):
        """Ensure the token and secret are passed correctly."""
        with self.settings(SURVEYGIZMO_API_TOKEN='mytoken',
                           SURVEYGIZMO_API_TOKEN_SECRET='mysecret'):
            add_email_to_campaign('general', '*****@*****.**')

            url = mock_requests.put.call_args[0][0]
            ok_('api_token=mytoken' in url)
            ok_('api_token_secret=mysecret' in url)
예제 #9
0
 def test_early_exit(self, mock_requests):
     """
     If there are no creds, don't hit the API and return an empty
     list.
     """
     with self.settings(SURVEYGIZMO_API_TOKEN=None,
                        SURVEYGIZMO_API_TOKEN_SECRET=None):
         add_email_to_campaign('general', '*****@*****.**')
         ok_(not mock_requests.put.called)
예제 #10
0
 def test_early_exit(self, mock_requests):
     """
     If there are no creds, don't hit the API and return an empty
     list.
     """
     with self.settings(SURVEYGIZMO_API_TOKEN=None,
                        SURVEYGIZMO_API_TOKEN_SECRET=None):
         add_email_to_campaign('general', '*****@*****.**')
         ok_(not mock_requests.put.called)
예제 #11
0
    def test_creds(self, mock_requests):
        """Ensure the token and secret are passed correctly."""
        with self.settings(SURVEYGIZMO_API_TOKEN="mytoken",
                           SURVEYGIZMO_API_TOKEN_SECRET="mysecret"):
            add_email_to_campaign("general", "*****@*****.**")

            url = mock_requests.put.call_args[0][0]
            ok_("api_token=mytoken" in url)
            ok_("api_token_secret=mysecret" in url)
예제 #12
0
    def handle(self, **options):
        # We get the email addresses of all users that asked a question 2 days
        # ago. Then, all we have to do is send the email address to surveygizmo
        # and it does the rest.
        two_days_ago = date.today() - timedelta(days=2)
        yesterday = date.today() - timedelta(days=1)

        emails = Question.objects.filter(
            created__gte=two_days_ago, created__lt=yesterday
        ).values_list("creator__email", flat=True)

        for email in emails:
            add_email_to_campaign("askers", email)
예제 #13
0
    def handle(self, **options):
        # We get the email addresses of all users that asked a question 2 days
        # ago. Then, all we have to do is send the email address to surveygizmo
        # and it does the rest.
        two_days_ago = date.today() - timedelta(days=2)
        yesterday = date.today() - timedelta(days=1)

        emails = Question.objects.filter(
            created__gte=two_days_ago, created__lt=yesterday
        ).values_list("creator__email", flat=True)

        for email in emails:
            add_email_to_campaign("askers", email)

        statsd.gauge("survey.askers", len(emails))
예제 #14
0
def survey_recent_askers():
    """Add question askers to a surveygizmo campaign to get surveyed."""
    # We get the email addresses of all users that asked a question 2 days
    # ago. Then, all we have to do is send the email address to surveygizmo
    # and it does the rest.
    two_days_ago = date.today() - timedelta(days=2)
    yesterday = date.today() - timedelta(days=1)

    emails = (Question.objects.filter(created__gte=two_days_ago,
                                      created__lt=yesterday).values_list(
                                          'creator__email', flat=True))

    for email in emails:
        add_email_to_campaign('askers', email)

    statsd.gauge('survey.askers', len(emails))
예제 #15
0
파일: cron.py 프로젝트: MikkCZ/kitsune
def survey_recent_askers():
    """Add question askers to a surveygizmo campaign to get surveyed."""
    # We get the email addresses of all users that asked a question 2 days
    # ago. Then, all we have to do is send the email address to surveygizmo
    # and it does the rest.
    two_days_ago = date.today() - timedelta(days=2)
    yesterday = date.today() - timedelta(days=1)

    emails = (
        Question.objects
        .filter(created__gte=two_days_ago, created__lt=yesterday)
        .values_list('creator__email', flat=True))

    for email in emails:
        add_email_to_campaign('askers', email)

    statsd.gauge('survey.askers', len(emails))
예제 #16
0
def survey_recent_askers():
    """Add question askers to a surveygizmo campaign to get surveyed."""
    if settings.STAGE:
        # Only run this on prod, it doesn't need to be running multiple times
        # from different places.
        return

    # We get the email addresses of all users that asked a question 2 days
    # ago. Then, all we have to do is send the email address to surveygizmo
    # and it does the rest.
    two_days_ago = date.today() - timedelta(days=2)
    yesterday = date.today() - timedelta(days=1)

    emails = (Question.objects.filter(created__gte=two_days_ago,
                                      created__lt=yesterday).values_list(
                                          'creator__email', flat=True))
    for email in emails:
        add_email_to_campaign('askers', email)

    statsd.gauge('survey.askers', len(emails))
예제 #17
0
파일: cron.py 프로젝트: ChromiumEx/kitsune
def survey_recent_askers():
    """Add question askers to a surveygizmo campaign to get surveyed."""
    if settings.STAGE:
        # Only run this on prod, it doesn't need to be running multiple times
        # from different places.
        return

    # We get the email addresses of all users that asked a question 2 days
    # ago. Then, all we have to do is send the email address to surveygizmo
    # and it does the rest.
    two_days_ago = date.today() - timedelta(days=2)
    yesterday = date.today() - timedelta(days=1)

    emails = (
        Question.objects
        .filter(created__gte=two_days_ago, created__lt=yesterday)
        .values_list('creator__email', flat=True))
    for email in emails:
            add_email_to_campaign('askers', email)

    statsd.gauge('survey.askers', len(emails))