def create_es_backup(): try: logger.info("Weekly (%s) elasticsearch backup starting", datetime.date.today().strftime("%A")) create_elasticsearch_backup() logger.info("Weekly (%s) elasticsearch backup completed", datetime.date.today().strftime("%A")) slack_message = 'Weekly elasticsearch backup completed in {0} space'.format( get_app_name()) utils.post_to_slack(slack_message, '#bots') except Exception as error: logger.exception(error) slack_message = '*ERROR* elasticsearch backup failed for {0}. Check logs.'.format( get_app_name()) utils.post_to_slack(slack_message, '#bots')
def refresh_materialized_views(): """Update incremental aggregates, itemized schedules, materialized views, then slack a notification to the development team. """ manage.logger.info('Starting nightly refresh...') try: manage.refresh_materialized() download.clear_bucket() slack_message = '*Success* nightly updates for {0} completed'.format( get_app_name()) utils.post_to_slack(slack_message, '#bots') manage.logger.info(slack_message) except Exception as error: manage.logger.exception(error) slack_message = '*ERROR* nightly update failed for {0}. Check logs.'.format( get_app_name()) utils.post_to_slack(slack_message, '#bots')
def reload_all_aos(): logger.info("Weekly (%s) reload of all AOs starting", datetime.date.today().strftime("%A")) load_advisory_opinions() logger.info("Weekly (%s) reload of all AOs completed", datetime.date.today().strftime("%A")) slack_message = 'Weekly reload of all AOs completed in {0} space'.format( get_app_name()) utils.post_to_slack(slack_message, '#bots')
def reload_all_aos_when_change(): """ Reload all AOs if there were any new or modified AOs found for the past 24 hour period """ with db.engine.connect() as conn: row = conn.execute(DAILY_MODIFIED_STARTING_AO).first() if row: logger.info("AO found %s modified at %s", row["ao_no"], row["pg_date"]) logger.info("Daily (%s) reload of all AOs starting", datetime.date.today().strftime("%A")) load_advisory_opinions() logger.info("Daily (%s) reload of all AOs completed", datetime.date.today().strftime("%A")) slack_message = 'Daily reload of all AOs completed in {0} space'.format(get_app_name()) utils.post_to_slack(slack_message, '#bots') else: logger.info("No daily (%s) modified AOs found", datetime.date.today().strftime("%A")) slack_message = \ 'No modified AOs found for the day - Reload of all AOs skipped in {0} space'.format(get_app_name()) utils.post_to_slack(slack_message, '#bots')