AOSSIE-Org / AOSSIE-Org/PictoPy

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

Aberta
#805 7 comentários 1 reação 1 responsável Reivindicada por @Nithin9585 Ver no GitHub
backend enhancement
Linguagem predominante
Python
Estrelas
283
Forks
679
Merge médio
7d 2h
PRs com merge (30d)
3

Descrição

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
)

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.