BUG: Add images to album: success message shows requested count, not number actually added

Đang mở Phù hợp với người mới
#1,740 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 10 ngày

@avika269 đang làm issue này rồi.

Từ ngày 18/11/2026.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
84/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

Đọc backend/app/routes/albums.py và backend/app/database/albums.py để theo dõi hàm cơ sở dữ liệu chèn bao nhiêu hàng và route tạo phản hồi như thế nào. Thêm các bài kiểm thử route và cơ sở dữ liệu cho trường hợp IDs hợp lệ và không hợp lệ xen lẫn, IDs đã có trong album và IDs lặp lại; thông báo thành công phải cho biết số lượng thực sự được thêm. Chạy các bài kiểm thử liên quan đến những tệp này.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug enhancement
Is there an existing issue for this?
  • I have searched the existing issues
What happened?

I was reading through the album routes and noticed the "Added N images" message uses the length of the request, not what was actually inserted.

Where

backend/app/routes/albums.py (~line 375):

db_add_images_to_album(album_id, body.image_ids)
request_metadata_export(app_state)
return SuccessResponse(
    success=True, msg=f"Added {len(body.image_ids)} images to album"
)

db_add_images_to_album() in backend/app/database/albums.py only inserts IDs that exist in images, uses INSERT OR IGNORE, and returns nothing, so the route can't know how many rows were really added.

What I think happens

  • One existing ID plus one nonexistent ID: one row should be inserted, but the message should say "Added 2 images to album".
  • An ID already in the album is skipped by INSERT OR IGNORE but should still be counted in the message.
  • A repeated ID in one request should be counted twice in the message but inserted once.

I found this by reading the code and the existing tests. The existing 404 test mocks the DB function, so mixed valid/invalid IDs aren't covered.

Possible fix

Return cursor.rowcount from db_add_images_to_album() and use it in the route message, plus a route test and a DB test for the mixed and already-in-album cases.

Record
  • I agree to follow this project's Code of Conduct
Ngôn ngữ chính
Python
Star
320
Fork
771
Merge trung bình
9 ngày 5 giờ
Pull request đã merge (30 ngày)
15

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của AOSSIE-Org/PictoPy

Tất cả issue của AOSSIE-Org/PictoPy

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.