def get_user_activity_summary(records: List[QuerySet]) -> Dict[(str, Dict[(str, Any)])]:
    summary: Dict[(str, Dict[(str, Any)])] = {}

    def update(action: str, record: QuerySet) -> None:
        if (action not in summary):
            summary[action] = dict(count=record.count, last_visit=record.last_visit)
        else:
            summary[action]['count'] += record.count
            summary[action]['last_visit'] = max(summary[action]['last_visit'], record.last_visit)
    if records:
        summary['name'] = records[0].user_profile.full_name
    for record in records:
        client = record.client.name
        query = record.query
        update('use', record)
        if (client == 'API'):
            m = re.match('/api/.*/external/(.*)', query)
            if m:
                client = m.group(1)
                update(client, record)
        if client.startswith('desktop'):
            update('desktop', record)
        if (client == 'website'):
            update('website', record)
        if (('send_message' in query) or re.search('/api/.*/external/.*', query)):
            update('send', record)
        if (query in ['/json/update_pointer', '/json/users/me/pointer', '/api/v1/update_pointer', 'update_pointer_backend']):
            update('pointer', record)
        update(client, record)
    return summary
def get_user_activity_summary(records: List[QuerySet]) -> Dict[(str, Dict[(str, Any)])]:
    summary: Dict[(str, Dict[(str, Any)])] = {}

    def update(action: str, record: QuerySet) -> None:
        if (action not in summary):
            summary[action] = dict(count=record.count, last_visit=record.last_visit)
        else:
            summary[action]['count'] += record.count
            summary[action]['last_visit'] = max(summary[action]['last_visit'], record.last_visit)
    if records:
        summary['name'] = records[0].user_profile.full_name
    for record in records:
        client = record.client.name
        query = record.query
        update('use', record)
        if (client == 'API'):
            m = re.match('/api/.*/external/(.*)', query)
            if m:
                client = m.group(1)
                update(client, record)
        if client.startswith('desktop'):
            update('desktop', record)
        if (client == 'website'):
            update('website', record)
        if (('send_message' in query) or re.search('/api/.*/external/.*', query)):
            update('send', record)
        if (query in ['/json/update_pointer', '/json/users/me/pointer', '/api/v1/update_pointer', 'update_pointer_backend']):
            update('pointer', record)
        update(client, record)
    return summary