BUG: Memories `video_count` becomes stale after video deletion

オープン
#1,773 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 4 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
半日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python, sql
領域
backend, databases

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
Python
スター
322
フォーク
793
平均マージ
6日 9時間
マージ済み PR(30日)
20

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

AOSSIE-Org/PictoPy のほかの issue

AOSSIE-Org/PictoPy の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。