Skip to content

feat: add the TInyBird resources for the search volume data #3178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 15, 2025
12 changes: 12 additions & 0 deletions services/libs/tinybird/datasources/searchVolume.datasource
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
SCHEMA >
`id` UInt64 `json:$.record.id`,
`insightsProjectId` UUID `json:$.record.insights_project_id`,
`project` String `json:$.record.project`,
`dataTimestamp` DateTime64(3) `json:$.record.data_timestamp`,
`volume` UInt64 `json:$.record.volume`,
`updatedAt` DateTime64(3) `json:$.record.updated_at`

ENGINE ReplacingMergeTree
ENGINE_PARTITION_KEY toYear(dataTimestamp)
ENGINE_SORTING_KEY slug, dataTimestamp
ENGINE_VER updatedAt
35 changes: 35 additions & 0 deletions services/libs/tinybird/pipes/search_volume.pipe
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
DESCRIPTION >
Serves the project search volume data for the `Search queries` widget

NODE searchVolume_pipe
SQL >
%
SELECT
insightsProjectId,
project,
formatDateTime(dataTimestamp, '%Y-%m-%d') AS dataTimestamp,
volume,
updatedAt
FROM searchVolume FINAL
WHERE
insightsProjectId = toUUID((select insightsProjectId from segments_filtered))
{% if defined(startDate) %}
AND searchVolume.dataTimestamp
>= {{
DateTime(
startDate,
description="Select records with dataTimestamp only after the given date",
required=False,
)
}}
{% end %}
{% if defined(endDate) %}
AND searchVolume.dataTimestamp
<= {{
DateTime(
endDate,
description="Select records with dataTimestamp only before the given date",
required=False,
)
}}
{% end %}
Loading
Oops, something went wrong.