update
This commit is contained in:
@@ -144,43 +144,27 @@ export class PipelinesHandler {
|
||||
|
||||
/**
|
||||
* Current mode: running/pending always shown, plus recent pipelines within timeRange.
|
||||
* Makes two parallel aggregation passes to ensure active pipelines are never missed:
|
||||
* 1. Recent pipelines (no status filter) — for time-range display
|
||||
* 2. Active pipelines (status: 'running') — guarantees we catch all running ones
|
||||
* Fetches a generous page of recent pipelines per project (100), then splits into
|
||||
* active (running/pending/waiting) and the rest. Active are always shown; the rest
|
||||
* is filtered by timeRange.
|
||||
*/
|
||||
private async fetchCurrentPipelines(
|
||||
provider: BaseProvider,
|
||||
timeRange: string,
|
||||
): Promise<interfaces.data.IPipeline[]> {
|
||||
const projects = await provider.getProjects();
|
||||
|
||||
// Two parallel fetches: recent + explicitly active
|
||||
const [recentPipelines, activePipelines] = await Promise.all([
|
||||
this.fetchAggregatedPipelines(provider, projects, { perPage: 50 }),
|
||||
this.fetchAggregatedPipelines(provider, projects, { status: 'running', perPage: 50 }),
|
||||
]);
|
||||
|
||||
// Merge and deduplicate (active first so they take precedence)
|
||||
const seenIds = new Set<string>();
|
||||
const merged: interfaces.data.IPipeline[] = [];
|
||||
for (const p of [...activePipelines, ...recentPipelines]) {
|
||||
const key = `${p.connectionId}:${p.projectId}:${p.id}`;
|
||||
if (!seenIds.has(key)) {
|
||||
seenIds.add(key);
|
||||
merged.push(p);
|
||||
}
|
||||
}
|
||||
const allPipelines = await this.fetchAggregatedPipelines(provider, projects, { perPage: 100 });
|
||||
|
||||
// Running/pending pipelines are always shown regardless of time
|
||||
const active = merged.filter(
|
||||
const active = allPipelines.filter(
|
||||
(p) => p.status === 'running' || p.status === 'pending' || p.status === 'waiting',
|
||||
);
|
||||
const rest = merged.filter(
|
||||
const rest = allPipelines.filter(
|
||||
(p) => p.status !== 'running' && p.status !== 'pending' && p.status !== 'waiting',
|
||||
);
|
||||
const filteredRest = this.filterByTimeRange(rest, timeRange);
|
||||
|
||||
// Final dedup (active pipelines may also appear in filtered rest)
|
||||
// Deduplicate (active pipelines may also appear in filtered rest)
|
||||
const activeIds = new Set(active.map((p) => `${p.connectionId}:${p.projectId}:${p.id}`));
|
||||
const uniqueRest = filteredRest.filter(
|
||||
(p) => !activeIds.has(`${p.connectionId}:${p.projectId}:${p.id}`),
|
||||
|
||||
Reference in New Issue
Block a user