Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

4.0 KB
Raw Blame
NODE count
SQL >

%
    SELECT
        count() as count
    FROM dub_api_logs
    WHERE
        workspace_id = {{ String(workspaceId) }}
        {% if defined(start) and defined(end) %}
            AND timestamp >= {{ DateTime(start, '2024-06-01 00:00:00') }}
            AND timestamp < {{ DateTime(end, '2024-06-07 00:00:00') }}
        {% end %}
        {% if defined(routePattern) %} AND route_pattern = {{ String(routePattern) }} {% end %}
        {% if defined(method) %} AND method = {{ String(method) }} {% end %}
        {% if defined(statusCode) %} AND status_code = {{ UInt16(statusCode) }} {% end %}
        {% if defined(tokenId) %} AND token_id = {{ String(tokenId) }} {% end %}
        {% if defined(requestId) %} AND id = {{ String(requestId) }} {% end %}
        {% if defined(requestType) %} AND request_type = {{ String(requestType) }} {% end %}



NODE count_by_route_pattern
SQL >

%
    SELECT
        route_pattern as routePattern,
        count() as count
    FROM dub_api_logs
    WHERE
        workspace_id = {{ String(workspaceId) }}
        {% if defined(start) and defined(end) %}
            AND timestamp >= {{ DateTime(start, '2024-06-01 00:00:00') }}
            AND timestamp < {{ DateTime(end, '2024-06-07 00:00:00') }}
        {% end %}
        {% if defined(routePattern) %} AND route_pattern = {{ String(routePattern) }} {% end %}
        {% if defined(method) %} AND method = {{ String(method) }} {% end %}
        {% if defined(statusCode) %} AND status_code = {{ UInt16(statusCode) }} {% end %}
        {% if defined(tokenId) %} AND token_id = {{ String(tokenId) }} {% end %}
        {% if defined(requestId) %} AND id = {{ String(requestId) }} {% end %}
        {% if defined(requestType) %} AND request_type = {{ String(requestType) }} {% end %}
        AND route_pattern != ''
    GROUP BY route_pattern
    ORDER BY count DESC
    LIMIT 100



NODE count_by_status_code
SQL >

%
    SELECT
        status_code as statusCode,
        count() as count
    FROM dub_api_logs
    WHERE
        workspace_id = {{ String(workspaceId) }}
        {% if defined(start) and defined(end) %}
            AND timestamp >= {{ DateTime(start, '2024-06-01 00:00:00') }}
            AND timestamp < {{ DateTime(end, '2024-06-07 00:00:00') }}
        {% end %}
        {% if defined(routePattern) %} AND route_pattern = {{ String(routePattern) }} {% end %}
        {% if defined(method) %} AND method = {{ String(method) }} {% end %}
        {% if defined(statusCode) %} AND status_code = {{ UInt16(statusCode) }} {% end %}
        {% if defined(tokenId) %} AND token_id = {{ String(tokenId) }} {% end %}
        {% if defined(requestId) %} AND id = {{ String(requestId) }} {% end %}
        {% if defined(requestType) %} AND request_type = {{ String(requestType) }} {% end %}
    GROUP BY status_code
    ORDER BY count DESC



NODE count_by_method
SQL >

%
    SELECT
        method,
        count() as count
    FROM dub_api_logs
    WHERE
        workspace_id = {{ String(workspaceId) }}
        {% if defined(start) and defined(end) %}
            AND timestamp >= {{ DateTime(start, '2024-06-01 00:00:00') }}
            AND timestamp < {{ DateTime(end, '2024-06-07 00:00:00') }}
        {% end %}
        {% if defined(routePattern) %} AND route_pattern = {{ String(routePattern) }} {% end %}
        {% if defined(method) %} AND method = {{ String(method) }} {% end %}
        {% if defined(statusCode) %} AND status_code = {{ UInt16(statusCode) }} {% end %}
        {% if defined(tokenId) %} AND token_id = {{ String(tokenId) }} {% end %}
        {% if defined(requestId) %} AND id = {{ String(requestId) }} {% end %}
        {% if defined(requestType) %} AND request_type = {{ String(requestType) }} {% end %}
    GROUP BY method
    ORDER BY count DESC



NODE endpoint
SQL >

%
    SELECT *
    FROM
        {% if defined(groupBy) and groupBy == 'routePattern' %} count_by_route_pattern
        {% elif defined(groupBy) and groupBy == 'statusCode' %} count_by_status_code
        {% elif defined(groupBy) and groupBy == 'method' %} count_by_method
        {% else %} count
        {% end %}

TYPE ENDPOINT