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 摘要。