import requests
from datetime import datetime


def commit_in_last_year(commits_url: str, headers: dict) -> str:
    """
    11. Has there been a commit in the last year?
    """
    r = requests.get(commits_url, headers=headers).json()
    last_commit_date = r.get("commit").get("author").get("date")
    last_commit_date = datetime.strptime(last_commit_date, "%Y-%m-%dT%H:%M:%SZ")
    days_since_last_commit = (datetime.utcnow() - last_commit_date).days
    if days_since_last_commit > 365:
        message = f"[red]No. The last commit was {days_since_last_commit} days ago"
    else:
        message = f"[green]Yes. The last commit was on {datetime.strftime(last_commit_date, '%m-%d-%Y')} "
        message += f"which was {days_since_last_commit} days ago"

    return message