AOSSIE-Org / AOSSIE-Org/PictoPy

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

Abierto
#805 7 comentarios 1 reacción 1 asignado Reclamado por @Nithin9585 Ver en GitHub
backend enhancement
Lenguaje dominante
Python
Estrellas
283
Forks
679
Merge medio
7 d 2 h
PR fusionados (30 d)
3

Descripción

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
)

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.