Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions services/libs/tinybird/pipes/project_insights.pipe
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ DESCRIPTION >
- `slug`: Optional string for a single project slug (e.g., 'kubernetes')
- `slugs`: Optional array of project slugs for multi-project query (e.g., ['kubernetes', 'tensorflow'])
- `ids`: Optional array of project ids for multi-project query
- `isLF`: Optional boolean to filter by LF status
- `orderBy`: Optional string for dynamic sorting by any column (default: 'contributorCount')
- `orderDirection`: Optional string ('asc' or 'desc'), defaults to 'desc'
- `pageSize`: Optional integer for number of results per page (default: 10)
- `page`: Optional integer for page number, 0-based (default: 0)
Comment on lines +8 to +12
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DESCRIPTION says orderBy can sort by “any column”, and the query passes the request value directly into column(orderBy, ...). If a client supplies a non-existent or non-orderable column, the endpoint will error at runtime. Consider documenting an explicit list of supported orderBy values (like other list endpoints do) and/or enforcing an allowlist/fallback to the default when an unsupported value is provided.

Copilot uses AI. Check for mistakes.
- At least one of `slug`, `slugs`, or `ids` should be provided.
- Response: Project records with all insights metrics including achievements as array of (leaderboardType, rank, totalCount) tuples
TAGS ""Insights, Widget", "Project""
Expand Down Expand Up @@ -50,3 +55,13 @@ SQL >
AND id
IN {{ Array(ids, 'String', description="Filter by project id list", required=False) }}
{% end %}
{% if defined(isLF) %}
AND isLF = {{ Boolean(isLF, description="Filter by LF status", required=False) }}
{% end %}
ORDER BY
{{ column(orderBy, 'contributorCount') }}
{% if defined(orderDirection) and orderDirection == 'asc' %} ASC
{% else %} DESC
{% end %}
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pagination is now supported via LIMIT/OFFSET, but the ORDER BY only uses the user-selected sort column. If many rows share the same value for that column (e.g., contributorCount), page boundaries can be unstable/non-deterministic across requests. Consider adding a deterministic tiebreaker (e.g., slug or id) after the primary sort key so pagination is consistent.

Suggested change
{% end %}
{% end %},
id ASC

Copilot uses AI. Check for mistakes.
LIMIT {{ Int32(pageSize, 10) }}
OFFSET {{ Int32(page, 0) * Int32(pageSize, 10) }}
Loading