"""get_growth_date_range task.""" import datetime from garcon import task from activity_detector.flows.analytics_digest import config @task.decorate(timeout=300) def get_growth_date_range(activity, start_date, end_date): """Get the date range for which to run the growth percentages. Args: activity (ActivityWorker): garcon activity worker Returns: dict: start_date (str): the start date end_date (str): the end date """ return { 'start_date': ( datetime.datetime.strptime(start_date, config.DATE_FORMAT) - datetime.timedelta(days=7) ).strftime(config.DATE_FORMAT), 'end_date': ( datetime.datetime.strptime(end_date, config.DATE_FORMAT) - datetime.timedelta(days=7) ).strftime(config.DATE_FORMAT) }