Add 50000 limit to aggregate survey query results#53451
Conversation
Generated-By: PostHog Code Task-Id: 7c62a2f6-3302-4f0b-9b0a-b426f3465735
|
Size Change: +48 B (0%) Total Size: 127 MB ℹ️ View Unchanged
|
Prompt To Fix All With AIThis is a comment left during a code review.
Path: frontend/src/scenes/surveys/utils.ts
Line: 588
Comment:
**Inconsistent limit pattern vs `buildOpenEndedQuery`**
`buildOpenEndedQuery` (line 595) accepts a configurable `limit: number = 50000` parameter and interpolates it as `LIMIT ${limit}`. This function now hardcodes `50000` directly in the query string. The two functions share the same magic number but express it differently, so a future change to the limit would need to be updated in both places.
Consider extracting a shared constant or following the same parameter pattern:
```suggestion
return `SELECT question_id, label, cnt FROM (${branches.join('\nUNION ALL\n')}) LIMIT ${SURVEY_QUERY_LIMIT}`
```
where `const SURVEY_QUERY_LIMIT = 50000` is defined at module scope and reused by both functions.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(surveys): Add 50000 limit to aggrega..." | Re-trigger Greptile |
| } | ||
|
|
||
| return `SELECT question_id, label, cnt FROM (${branches.join('\nUNION ALL\n')})` | ||
| return `SELECT question_id, label, cnt FROM (${branches.join('\nUNION ALL\n')}) LIMIT 50000` |
There was a problem hiding this comment.
Inconsistent limit pattern vs
buildOpenEndedQuery
buildOpenEndedQuery (line 595) accepts a configurable limit: number = 50000 parameter and interpolates it as LIMIT ${limit}. This function now hardcodes 50000 directly in the query string. The two functions share the same magic number but express it differently, so a future change to the limit would need to be updated in both places.
Consider extracting a shared constant or following the same parameter pattern:
| return `SELECT question_id, label, cnt FROM (${branches.join('\nUNION ALL\n')}) LIMIT 50000` | |
| return `SELECT question_id, label, cnt FROM (${branches.join('\nUNION ALL\n')}) LIMIT ${SURVEY_QUERY_LIMIT}` |
where const SURVEY_QUERY_LIMIT = 50000 is defined at module scope and reused by both functions.
Prompt To Fix With AI
This is a comment left during a code review.
Path: frontend/src/scenes/surveys/utils.ts
Line: 588
Comment:
**Inconsistent limit pattern vs `buildOpenEndedQuery`**
`buildOpenEndedQuery` (line 595) accepts a configurable `limit: number = 50000` parameter and interpolates it as `LIMIT ${limit}`. This function now hardcodes `50000` directly in the query string. The two functions share the same magic number but express it differently, so a future change to the limit would need to be updated in both places.
Consider extracting a shared constant or following the same parameter pattern:
```suggestion
return `SELECT question_id, label, cnt FROM (${branches.join('\nUNION ALL\n')}) LIMIT ${SURVEY_QUERY_LIMIT}`
```
where `const SURVEY_QUERY_LIMIT = 50000` is defined at module scope and reused by both functions.
How can I resolve this? If you propose a fix, please make it concise.|
🎭 Playwright report · View test results →
These issues are not necessarily caused by your changes. |
Problem
survey aggregate query has no defined limit, causing it to be capped at 100
this fix was attempted in #51897, but i missed this one 🙈
Changes
adds explicit limit to the aggregate query
How did you test this code?
see manual testing notes in ticket: https://posthoghelp.zendesk.com/agent/tickets/52678
Created with PostHog Code