VERSION 1
TOKEN "endpoint__get_active_keys_endpoint_read_5876" READ

NODE endpoint__get_active_keys_0
SQL >

    %
    SELECT count(DISTINCT keyId) as active, toStartOfDay(time) as time from mv_billing_hourly_active_keys where
            workspaceId = {{ String(workspaceId, required=True )}}
            {% if defined(apiId) %}
            and apiId ={{ String(apiId) }}
            {%end if %}

            and time > now() - INTERVAL 30 day
        GROUP BY  time,keyId
