Skip to content

Commit 7c03dba

Browse files
committed
fix: using selected segments
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
1 parent c87e8e7 commit 7c03dba

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

frontend/src/modules/activity/components/activity-timeline.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,6 @@ const fetchActivities = async ({ reset } = { reset: false }) => {
378378
if (selectedSegment.value) {
379379
querySegments = [selectedSegment.value];
380380
} else if (segments.value.length > 0) {
381-
// Use entity-specific segments (e.g. member's actual repos) — avoids sending
382-
// all project group leaf IDs to Tinybird which causes 400 for large groups.
383381
querySegments = segments.value.map((s) => s.id);
384382
} else {
385383
querySegments = [];

services/libs/data-access-layer/src/activities/tinybirdAdapter.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
import { getServiceLogger } from '@crowd/logging'
2+
13
import { IQueryActivitiesParameters } from './types'
24

5+
const log = getServiceLogger()
6+
37
/* =========================
48
* Constants & basic helpers
59
* ========================= */
@@ -455,9 +459,19 @@ const emitGroup = (params: TBParams, n: number, g: GroupFilter): void => {
455459
export function buildActivitiesParams(arg: ExtendedArgs): TBParams {
456460
const params: TBParams = {}
457461

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
461475

462476
// Optional pass-throughs (arrays, strings, booleans)
463477
const repos = toStringArray(arg.repos)

0 commit comments

Comments
 (0)