AOSSIE-Org / AOSSIE-Org/PictoPy

[Bug] Performance Issue: toggle-favourite fetches ALL images instead of single image lookup

未關閉
#805 7 則留言 1 個 reaction 已指派 1 人 已被 @Nithin9585 認領 在 GitHub 檢視
backend enhancement
主要語言
Python
星號
283
分支
679
平均合併
7 天 2 小時
30 天內合併 PR
3

描述

The `/images/toggle-favourite` endpoint has a significant performance issue. When toggling the favourite status of a single image, the code fetches **ALL images** from the database and then iterates through them to find the one image needed.

This is an O(n) operation when it should be O(1).

## Location

**File:** [backend/app/routes/images.py](cci:7://file:///c:/Users/Nithi/OneDrive/Desktop/gsoc/PictoPy/backend/app/routes/images.py:0:0-0:0) (Lines 108-110)

## Current Code (Problematic)

```python
# Fetch updated status to return
image = next(
(img for img in db_get_all_images() if img["id"] == image_id), None
)

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。