hts/internal/tinybird/pipes/endpoint_billing_get_active...

19 lines
682 B
Plaintext

VERSION 2
TOKEN "endpoint__billing_get_active_keys_usage__v1_endpoint_read_7945" READ
TOKEN "endpoint_billing_get_active_keys_usage__v2_endpoint_read_9814" READ
NODE get_usage
SQL >
%
SELECT count(DISTINCT keyId) as usage
FROM mv_billing_hourly_active_keys
where
workspaceId = {{ String(workspaceId, required=True) }}
{% if defined(apiId) %}
and apiId ={{ String(apiId) }}
{%end if %}
and time >= toStartOfDay(fromUnixTimestamp64Milli({{ Int64(start, required=True) }}))
and time <= toStartOfDay(fromUnixTimestamp64Milli({{ Int64(end, required=True) }}))+INTERVAL 1 DAY