def add_inactivity_periods(daily_summaries):
    """
    Iterate over the daily summaries once forwards and once backwards to supply inactivity information
    to adjacent days to the start and end dates.
    """
    inactive_days, summary_before, first_inactive_day = None, None, None
    for date, summary in sorted(daily_summaries.items()):
        no_trip_data = not any([summary['has_trips'], summary['is_complete']])
        if no_trip_data:
            if not inactive_days:
                inactive_days = 0
            inactive_days += 1
            if not first_inactive_day:
                first_inactive_day = date
        else:
            inactive_days = None
            first_inactive_day = None
        summary['consecutive_inactive_days'] = inactive_days
        summary['first_inactive_day'] = first_inactive_day
        if summary_before is not None:
            summary['before_is_complete'] = summary_before['is_complete'
                ] is True
        else:
            summary['before_is_complete'] = False
        summary_before = summary
    summary_after = None
    latest_streak_max = 0
    for date, summary in sorted(daily_summaries.items(), reverse=True):
        if summary['consecutive_inactive_days']:
            latest_streak_max = max(latest_streak_max, summary[
                'consecutive_inactive_days'])
            summary['inactive_day_streak'] = latest_streak_max
        if summary_after is not None:
            summary['after_is_complete'] = summary_after['is_complete'] is True
        else:
            summary['after_is_complete'] = False
        summary_after = summary
    max_inactivity_streak = latest_streak_max if latest_streak_max else None
    for date, summary in daily_summaries.items():
        summary['max_inactivity_streak'] = max_inactivity_streak
    return daily_summaries
