FlowFuse / FlowFuse/flowfuse

Optimization: Reduce the number of api calls when retrieving team performance instance data

Open
#5,604 0 comments 0 reactions 0 assignees View on GitHub
task
Dominant language
JavaScript
Stars
400
Forks
89
Avg merge
1d 21h
Merged PRs (30d)
146

Description

### Description

When opening the team performance page, the `getTeamInstances` API client retrieves a list of instances using the following endpoint:
`/api/v1/teams/${teamId}/projects`.

However, this endpoint does **not** include the `meta` key, which is required to display an instance's status. As a result, the system iterates over the retrieved list of instances and performs individual API calls to `/api/v1/projects/${instance.id}` to get the `meta` data.

Bare in mind that both endpoints return an identical payload instance with the exception of the meta key.

### This implementation causes:
- **Significant inefficiency** due to the **n+1 API call issue**, especially with larger datasets (e.g., 75 instances generating 75 additional API calls).
- Increased server load and latency.
- Potential compatibility issues with rate limits or redundant network traffic.

For example, on the **FF team**, when accessing the team performance tab, the initial `getTeamInstances` API call retrieves 75 instances and queues **75 subsequent requests** to fetch `meta` data.

### Epic/Story

_No response_

### Have you provided an initial effort estimate for this issue?

I have provided an initial effort estimate

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.