def postUpdateHook(cls, events, updated_attr_list, is_new_list):
        """
        To run after models have been updated
        """
        for (event, updated_attrs) in zip(events, updated_attr_list):
            try:
                if event.within_a_day and "alliance_selections_json" in updated_attrs:
                    # Send updated alliances notification
                    logging.info("Sending alliance notifications for {}".format(event.key_name))
                    NotificationHelper.send_alliance_update(event)
            except Exception:
                logging.error("Error sending alliance update notification for {}".format(event.key_name))
                logging.error(traceback.format_exc())

            try:
                event.timezone_id = EventHelper.get_timezone_id(event.location, event.key.id())
                cls.createOrUpdate(event, run_post_update_hook=False)
            except Exception:
                logging.warning("Timezone update for event {} failed!".format(event.key_name))

        # Enqueue task to calculate district points
        for event in events:
            taskqueue.add(
                url='/tasks/math/do/district_points_calc/{}'.format(event.key.id()),
                method='GET')
    def postUpdateHook(cls, event_details_list, updated_attr_list,
                       is_new_list):
        """
        To run after models have been updated
        """
        for (event_details, updated_attrs) in zip(event_details_list,
                                                  updated_attr_list):
            event = Event.get_by_id(event_details.key.id())
            try:
                if event.within_a_day and "alliance_selections" in updated_attrs:
                    # Send updated alliances notification
                    logging.info(
                        "Sending alliance notifications for {}".format(
                            event.key_name))
                    NotificationHelper.send_alliance_update(event)
            except Exception:
                logging.error(
                    "Error sending alliance update notification for {}".format(
                        event.key_name))
                logging.error(traceback.format_exc())

            # Enqueue task to calculate district points
            try:
                taskqueue.add(
                    url='/tasks/math/do/district_points_calc/{}'.format(
                        event.key.id()),
                    method='GET')
            except Exception:
                logging.error(
                    "Error enqueuing district_points_calc for {}".format(
                        event.key.id()))
                logging.error(traceback.format_exc())
Exemple #3
0
    def postUpdateHook(cls, events, updated_attr_list, is_new_list):
        """
        To run after models have been updated
        """
        for (event, updated_attrs) in zip(events, updated_attr_list):
            try:
                if event.within_a_day and "alliance_selections_json" in updated_attrs:
                    # Send updated alliances notification
                    logging.info(
                        "Sending alliance notifications for {}".format(
                            event.key_name))
                    NotificationHelper.send_alliance_update(event)
            except Exception:
                logging.error(
                    "Error sending alliance update notification for {}".format(
                        event.key_name))
                logging.error(traceback.format_exc())

            try:
                event.timezone_id = EventHelper.get_timezone_id(
                    event.location, event.key.id())
                cls.createOrUpdate(event, run_post_update_hook=False)
            except Exception:
                logging.warning("Timezone update for event {} failed!".format(
                    event.key_name))

        # Enqueue task to calculate district points
        for event in events:
            taskqueue.add(url='/tasks/math/do/district_points_calc/{}'.format(
                event.key.id()),
                          method='GET')
    def postUpdateHook(cls, event_details_list, updated_attr_list,
                       is_new_list):
        """
        To run after models have been updated
        """
        for (event_details, updated_attrs) in zip(event_details_list,
                                                  updated_attr_list):
            event = Event.get_by_id(event_details.key.id())
            if event.within_a_day and "alliance_selections" in updated_attrs:
                try:
                    NotificationHelper.send_alliance_update(event)
                except Exception:
                    logging.error(
                        "Error sending alliance update notification for {}".
                        format(event.key_name))
                    logging.error(traceback.format_exc())
                try:
                    TBANSHelper.alliance_selection(event)
                except Exception:
                    logging.error(
                        "Error sending alliance update notification for {}".
                        format(event.key_name))
                    logging.error(traceback.format_exc())

            # Enqueue task to calculate district points
            try:
                taskqueue.add(
                    url='/tasks/math/do/district_points_calc/{}'.format(
                        event.key.id()),
                    method='GET')
            except Exception:
                logging.error(
                    "Error enqueuing district_points_calc for {}".format(
                        event.key.id()))
                logging.error(traceback.format_exc())

            # Enqueue task to calculate event team status
            try:
                taskqueue.add(url='/tasks/math/do/event_team_status/{}'.format(
                    event.key.id()),
                              method='GET')
            except Exception:
                logging.error(
                    "Error enqueuing event_team_status for {}".format(
                        event.key.id()))
                logging.error(traceback.format_exc())

            try:
                FirebasePusher.update_event_details(event_details)
            except Exception:
                logging.warning("Firebase update_event_details failed!")
Exemple #5
0
 def postUpdateHook(cls, event_details_list, updated_attr_list, is_new_list):
     """
     To run after models have been updated
     """
     for (event_details, updated_attrs) in zip(event_details_list, updated_attr_list):
         event = Event.get_by_id(event_details.key.id())
         try:
             if event.within_a_day and "alliance_selections" in updated_attrs:
                 # Send updated alliances notification
                 logging.info("Sending alliance notifications for {}".format(event.key_name))
                 NotificationHelper.send_alliance_update(event)
         except Exception:
             logging.error("Error sending alliance update notification for {}".format(event.key_name))
             logging.error(traceback.format_exc())
Exemple #6
0
    def postUpdateHook(cls, event_details_list, updated_attr_list, is_new_list):
        """
        To run after models have been updated
        """
        for (event_details, updated_attrs) in zip(event_details_list, updated_attr_list):
            event = Event.get_by_id(event_details.key.id())
            try:
                if event.within_a_day and "alliance_selections" in updated_attrs:
                    # Send updated alliances notification
                    logging.info("Sending alliance notifications for {}".format(event.key_name))
                    NotificationHelper.send_alliance_update(event)
            except Exception:
                logging.error("Error sending alliance update notification for {}".format(event.key_name))
                logging.error(traceback.format_exc())

            # Enqueue task to calculate district points
            try:
                taskqueue.add(
                    url='/tasks/math/do/district_points_calc/{}'.format(event.key.id()),
                    method='GET')
            except Exception:
                logging.error("Error enqueuing district_points_calc for {}".format(event.key.id()))
                logging.error(traceback.format_exc())