def METHOD_NAME(project: Project, records: Sequence[Record]) -> Mapping[str, Any]:
    # This reads a little strange, but remember that records are returned in
    # reverse chronological order, and we query the database in chronological
    # order.
    # NOTE: This doesn't account for any issues that are filtered out later.
    start = records[-1].datetime
    end = records[0].datetime
    groups = Group.objects.in_bulk(record.value.event.group_id for record in records)
    tenant_ids = {"organization_id": project.organization_id}
    return {
        "project": project,
        "groups": groups,
        "rules": Rule.objects.in_bulk(
            itertools.chain.from_iterable(record.value.rules for record in records)
        ),
        "event_counts": tsdb.get_sums(
            TSDBModel.group,
            list(groups.keys()),
            start,
            end,
            tenant_ids=tenant_ids,
        ),
        "user_counts": tsdb.get_distinct_counts_totals(
            TSDBModel.users_affected_by_group,
            list(groups.keys()),
            start,
            end,
            tenant_ids=tenant_ids,
        ),
    }