"""Package related to reserve payouts with commands-functions.""" import logging from accounting.bin.build_helper import commands from accounting.flows.reserve_payouts import setting as reserve_payout_setting from accounting.flows.reserve_payouts.connectors import dynamodb from accounting.flows.reserve_payouts.connectors import mysql from accounting.util import dynamodb as dynamodb_util from accounting.util import sqs @commands.prevent_prod_execution def dynamodb_clean(): """Clean reserve payouts DynamoDb table.""" table = dynamodb_util.get_dynamodb_table( reserve_payout_setting.DYNAMODB_TABLE) with table.batch_writer() as batch_writer: for key in dynamodb.get_table_label_ids(): batch_writer.delete_item(Key=key) @commands.prevent_prod_execution def sqs_clean(): """Clean reserve payouts SQS queue.""" queue = sqs.get_queue_by_name(reserve_payout_setting.SQS_QUEUE) queue.purge() def filter_phys_transactions(period_id): """Cleanup and populate temp table with physical transaction data. Args: period_id (int): period id to filter data """ logging.info('Truncating temporary Table...') mysql.truncate_reserves_temp_table() logging.info('Inserting data to the temporary table...') rowcount = mysql.populate_reserves_temp_table(period_id) logging.info('Done. Affected row count: {}'.format(rowcount))