from datetime import datetime


def get_issues_and_prs_for_repo(repo, time_delta):
    """
    Retrieve new issues and PRs for the provided user and time period.
    """
    result = {"issues": [], "pulls": []}

    since_dt = datetime.now() - time_delta
    issues = list(repo.get_issues(since=since_dt))

    for issue in issues:
        # Convert Python object in a native Python type (dict)
        issue_dict = issue.raw_data
        issue_dict["repository"] = issue.repository.raw_data

        if issue.pull_request:
            result["pulls"].append(issue_dict)
        else:
            result["issues"].append(issue_dict)

        # Remove fields which we don't need to spin things up
        if "body" in issue_dict:
            del issue_dict["body"]

    return result