def sent_messages_report(realm: str) -> str:
    title = ('Recently sent messages for ' + realm)
    cols = ['Date', 'Humans', 'Bots']
    query = SQL("\n        select\n            series.day::date,\n            humans.cnt,\n            bots.cnt\n        from (\n            select generate_series(\n                (now()::date - interval '2 week'),\n                now()::date,\n                interval '1 day'\n            ) as day\n        ) as series\n        left join (\n            select\n                date_sent::date date_sent,\n                count(*) cnt\n            from zerver_message m\n            join zerver_userprofile up on up.id = m.sender_id\n            join zerver_realm r on r.id = up.realm_id\n            where\n                r.string_id = %s\n            and\n                (not up.is_bot)\n            and\n                date_sent > now() - interval '2 week'\n            group by\n                date_sent::date\n            order by\n                date_sent::date\n        ) humans on\n            series.day = humans.date_sent\n        left join (\n            select\n                date_sent::date date_sent,\n                count(*) cnt\n            from zerver_message m\n            join zerver_userprofile up on up.id = m.sender_id\n            join zerver_realm r on r.id = up.realm_id\n            where\n                r.string_id = %s\n            and\n                up.is_bot\n            and\n                date_sent > now() - interval '2 week'\n            group by\n                date_sent::date\n            order by\n                date_sent::date\n        ) bots on\n            series.day = bots.date_sent\n    ")
    cursor = connection.cursor()
    cursor.execute(query, [realm, realm])
    rows = cursor.fetchall()
    cursor.close()
    return make_table(title, cols, rows)
def sent_messages_report(realm: str) -> str:
    title = ('Recently sent messages for ' + realm)
    cols = ['Date', 'Humans', 'Bots']
    query = SQL("\n        select\n            series.day::date,\n            humans.cnt,\n            bots.cnt\n        from (\n            select generate_series(\n                (now()::date - interval '2 week'),\n                now()::date,\n                interval '1 day'\n            ) as day\n        ) as series\n        left join (\n            select\n                date_sent::date date_sent,\n                count(*) cnt\n            from zerver_message m\n            join zerver_userprofile up on up.id = m.sender_id\n            join zerver_realm r on r.id = up.realm_id\n            where\n                r.string_id = %s\n            and\n                (not up.is_bot)\n            and\n                date_sent > now() - interval '2 week'\n            group by\n                date_sent::date\n            order by\n                date_sent::date\n        ) humans on\n            series.day = humans.date_sent\n        left join (\n            select\n                date_sent::date date_sent,\n                count(*) cnt\n            from zerver_message m\n            join zerver_userprofile up on up.id = m.sender_id\n            join zerver_realm r on r.id = up.realm_id\n            where\n                r.string_id = %s\n            and\n                up.is_bot\n            and\n                date_sent > now() - interval '2 week'\n            group by\n                date_sent::date\n            order by\n                date_sent::date\n        ) bots on\n            series.day = bots.date_sent\n    ")
    cursor = connection.cursor()
    cursor.execute(query, [realm, realm])
    rows = cursor.fetchall()
    cursor.close()
    return make_table(title, cols, rows)