|
| 1 | +import { getServiceLogger } from '@crowd/logging' |
| 2 | + |
1 | 3 | import { IQueryActivitiesParameters } from './types' |
2 | 4 |
|
| 5 | +const log = getServiceLogger() |
| 6 | + |
3 | 7 | /* ========================= |
4 | 8 | * Constants & basic helpers |
5 | 9 | * ========================= */ |
@@ -455,9 +459,19 @@ const emitGroup = (params: TBParams, n: number, g: GroupFilter): void => { |
455 | 459 | export function buildActivitiesParams(arg: ExtendedArgs): TBParams { |
456 | 460 | const params: TBParams = {} |
457 | 461 |
|
458 | | - // segments as Array(String) |
459 | | - const segments = toStringArray(arg.segmentIds) |
460 | | - if (segments && segments.length) params.segments = segments |
| 462 | + // segments as Array(String) — cap at 500 to avoid Tinybird 400 on large project groups. |
| 463 | + // When an entity filter (memberId/orgId) is present this slice is a preview; users can |
| 464 | + // drill into a specific segment for full results. |
| 465 | + const MAX_SEGMENTS = 7500 |
| 466 | + const allSegments = toStringArray(arg.segmentIds) |
| 467 | + if (allSegments.length > MAX_SEGMENTS) { |
| 468 | + log.warn( |
| 469 | + { totalSegments: allSegments.length, cappedAt: MAX_SEGMENTS }, |
| 470 | + 'Tinybird segment list truncated — pass a specific segmentId to see full results', |
| 471 | + ) |
| 472 | + } |
| 473 | + const segments = allSegments.slice(0, MAX_SEGMENTS) |
| 474 | + if (segments.length) params.segments = segments |
461 | 475 |
|
462 | 476 | // Optional pass-throughs (arrays, strings, booleans) |
463 | 477 | const repos = toStringArray(arg.repos) |
|
0 commit comments