Exemple #1
0
                NotificationHelper.send_schedule_update(event)
            except Exception, exception:
                logging.error("Eror sending schedule updates for: {}".format(
                    event.key_name))
        '''
        Enqueue firebase push
        '''
        affected_stats_event_keys = set()
        for (match, updated_attrs, is_new) in zip(matches, updated_attr_list,
                                                  is_new_list):
            # Only attrs that affect stats
            if is_new or set(['alliances_json', 'score_breakdown_json'
                              ]).intersection(set(updated_attrs)) != set():
                affected_stats_event_keys.add(match.event.id())
            try:
                FirebasePusher.update_match(match)
            except Exception:
                logging.warning("Firebase update_match failed!")

        # Enqueue statistics
        for event_key in affected_stats_event_keys:
            # Enqueue task to calculate matchstats
            try:
                taskqueue.add(url='/tasks/math/do/event_matchstats/' +
                              event_key,
                              method='GET')
            except Exception:
                logging.error("Error enqueuing event_matchstats for {}".format(
                    event_key))
                logging.error(traceback.format_exc())
                NotificationHelper.send_schedule_update(event)
            except Exception, exception:
                logging.error("Eror sending schedule updates for: {}".format(
                    event.key_name))
        '''
        Enqueue firebase push
        '''
        affected_stats_event_keys = set()
        for (match, updated_attrs, is_new) in zip(matches, updated_attr_list,
                                                  is_new_list):
            # Only attrs that affect stats
            if is_new or set(['alliances_json', 'score_breakdown_json'
                              ]).intersection(set(updated_attrs)) != set():
                affected_stats_event_keys.add(match.event.id())
            try:
                FirebasePusher.update_match(match, updated_attrs)
            except Exception:
                logging.warning("Firebase update_match failed!")
                logging.warning(traceback.format_exc())

        # Enqueue statistics
        for event_key in affected_stats_event_keys:
            # Enqueue task to calculate matchstats
            try:
                taskqueue.add(url='/tasks/math/do/event_matchstats/' +
                              event_key,
                              method='GET')
            except Exception:
                logging.error("Error enqueuing event_matchstats for {}".format(
                    event_key))
                logging.error(traceback.format_exc())
        '''
        for event in unplayed_match_events:
            try:
                logging.info("Sending schedule updates for: {}".format(event.key_name))
                NotificationHelper.send_schedule_update(event)
            except Exception, exception:
                logging.error("Eror sending schedule updates for: {}".format(event.key_name))

        '''
        Enqueue firebase push
        '''
        event_keys = set()
        for match in matches:
            event_keys.add(match.event.id())
            try:
                FirebasePusher.update_match(match)
            except Exception:
                logging.warning("Enqueuing Firebase push failed!")

        # Enqueue task to calculate matchstats
        for event_key in event_keys:
            taskqueue.add(
                url='/tasks/math/do/event_matchstats/' + event_key,
                method='GET')

    @classmethod
    def updateMerge(self, new_match, old_match, auto_union=True):
        """
        Given an "old" and a "new" Match object, replace the fields in the
        "old" team that are present in the "new" team, but keep fields from
        the "old" team that are null in the "new" team.
            try:
                logging.info("Sending schedule updates for: {}".format(event.key_name))
                NotificationHelper.send_schedule_update(event)
            except Exception, exception:
                logging.error("Eror sending schedule updates for: {}".format(event.key_name))

        '''
        Enqueue firebase push
        '''
        affected_stats_event_keys = set()
        for (match, updated_attrs, is_new) in zip(matches, updated_attr_list, is_new_list):
            # Only attrs that affect stats
            if is_new or set(['alliances_json', 'score_breakdown_json']).intersection(set(updated_attrs)) != set():
                affected_stats_event_keys.add(match.event.id())
            try:
                FirebasePusher.update_match(match, updated_attrs)
            except Exception:
                logging.warning("Firebase update_match failed!")
                logging.warning(traceback.format_exc())

        # Enqueue statistics
        for event_key in affected_stats_event_keys:
            # Enqueue task to calculate matchstats
            try:
                taskqueue.add(
                    url='/tasks/math/do/event_matchstats/' + event_key,
                    method='GET')
            except Exception:
                logging.error("Error enqueuing event_matchstats for {}".format(event_key))
                logging.error(traceback.format_exc())