This commit is contained in:
2025-11-15 16:06:45 +08:00
parent c9c8eac734
commit 3e953e22b0
2 changed files with 2 additions and 0 deletions

View File

@@ -47,6 +47,7 @@ func GetUnusedImages() ([]model.Image, error) {
Where("NOT EXISTS (SELECT 1 FROM resource_images WHERE image_id = images.id)").
Where("NOT EXISTS (SELECT 1 FROM comment_images WHERE image_id = images.id)").
Where("NOT EXISTS (SELECT 1 FROM collection_images WHERE image_id = images.id)").
Where("NOT EXISTS (SELECT 1 FROM charactors WHERE image_id = images.id)").
Where("created_at < ?", oneDayAgo).
Find(&images).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {