BUG: Memories `video_count` becomes stale after video deletion

Abierto
#1,773 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 4 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
Medio día
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python, sql

Línea de trabajo

Start with the memory read queries and the _with_live_count() helper, which already compute live_image_count and map it to image_count; video_count has no matching live calculation. Check how memory_videos is joined in those queries, then add a live_video_count the same way. Done means that fetching a memory after its only video is deleted returns video_count of 0, and the regression tests for single, multiple, empty and mixed image/video memories pass.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug
Description

The video_count returned by Smart Memories API endpoints can become stale after videos are deleted from the library.

When a video associated with a memory is deleted, the corresponding entry in memory_videos is removed through the database's foreign-key cascade. However, the memory API continues returning the previously stored video_count instead of the actual number of associated videos.

Steps to Reproduce
  1. Create a memory containing one or more videos.
  2. Note the memory's video_count through the memories API.
  3. Delete the associated video(s) from the library.
  4. Fetch the memory again using the memories API.
Expected Behavior

The API should return the current number of videos associated with the memory.

For example, after deleting the only associated video:

  • videos should be an empty array.
  • video_count should be 0.
Actual Behavior

The videos array correctly reflects the deletion, but video_count can retain its previous value.

For example:

  • videos: []
  • video_count: 1
Root Cause

The database read queries calculate live_image_count dynamically and _with_live_count() maps it to image_count.

However, there was no corresponding live_video_count calculation or mapping. Consequently, video_count continued using its stored creation-time value.

Proposed Fix

Calculate live_video_count from the memory_videos association table in memory read queries and use that value when constructing API responses.

Verification

A fix has been implemented and tested locally.

  • Regression tests cover single-video deletion, multiple videos, empty-video memories, and mixed image/video memories.
  • Backend tests: 1,643 passed.
  • Frontend tests: 488 passed.
  • Ruff and Black checks passed.
Related Implementation

Fork: https://github.com/aakashkumarrr08-art/PictoPy

Branch: fix/memory-live-video-count

Commit: d4c891a3f4cec255793cf89e2aab3dfd060ac65a

Lenguaje dominante
Python
Estrellas
322
Forks
793
Merge medio
6 d 9 h
PR fusionados (30 d)
20

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de AOSSIE-Org/PictoPy

Todos los issues de AOSSIE-Org/PictoPy

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.