AOSSIE-Org / AOSSIE-Org/Ell-ena

BUG: N+1 query pattern in getTickets/getTasks/getTicketDetails causes performance issues

オープン
#149 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Dart
スター
54
フォーク
110
PR マージ指標
30日以内にマージされた PR はありません

説明

### Is there an existing issue for this?

- [x] I have searched the existing issues

### What happened?

**Issue Overview**

Several data-fetching methods in SupabaseService perform multiple sequential database queries for related user data.

For example:

- getTickets
- getTasks
- getTicketDetails
- getTaskDetails

These methods:
1. Fetch a list of tickets/tasks/comments.
2. Then, for each item, make additional queries to fetch creator/assignee/user info.

This creates an N+1 query pattern.

**Steps to Reproduce**

1. Create a team with multiple members.
2. Add 20–50 tasks or tickets.
3. Call getTickets() or getTasks().
4. Observe in logs or network panel that dozens of extra queries are executed (one per item for user info).

**Expected Behavior**

Related user data (creator, assignee, comment user) should be fetched in a single query using joins or views, not separate queries per row.
The number of database calls should be:

- O(1) per screen load
not
- O(n) per item.

**Actual Behavior**

For each ticket/task/comment:

- _getUserInfo() is called.
- This results in additional round-trips to the database.
- Performance degrades rapidly as data grows.

This will not scale for real teams.

**Why this issue matters**

This is not just micro-optimisation.
It directly affects:

- load time
- mobile data usage
- battery
- server cost
On real data sizes, this becomes a serious bottleneck.

### Record

- [x] I agree to follow this project's Code of Conduct
- [x] I want to work on this issue

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。