Skip to content

Commit

Permalink
correction of the part pointed out
Browse files Browse the repository at this point in the history
  • Loading branch information
azbcww committed Nov 28, 2023
1 parent b2d6939 commit b7a434d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions repository/gorm/stamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,22 @@ func (r *stampRepository) loadFilteredStamps(ctx context.Context, stampType repo
IDs = append(IDs, stamp.FileID)
}

ts := make([]uuid.UUID, 0, len(stamps))
thumbnails := make([]uuid.UUID, 0, len(stamps))
if err := r.db.
Table("files_thumbnails ft").
Table("files_thumbnails").
Select("file_id").
Where("file_id IN (?)", IDs).
Find(&ts).
Find(&thumbnails).
Error; err != nil {
return stampsWithThumbnail, err
return nil, err
}
tm := make(map[uuid.UUID]struct{}, len(ts))
for _, v := range ts {
tm[v] = struct{}{}
thumbnailExists := make(map[uuid.UUID]struct{}, len(thumbnails))
for _, v := range thumbnails {
thumbnailExists[v] = struct{}{}
}

for _, stamp := range stamps {
_, ok := tm[stamp.FileID]
_, ok := thumbnailExists[stamp.FileID]
stampsWithThumbnail = append(stampsWithThumbnail, &model.StampWithThumbnail{
Stamp: stamp,
HasThumbnail: ok,
Expand Down
2 changes: 1 addition & 1 deletion repository/stamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ type StampRepository interface {
// 引数にuuid.Nilを指定した場合、ErrNilIDを返します。
// DBによるエラーを返すことがあります。
DeleteStamp(id uuid.UUID) (err error)
// GetAllStampsWithThumbnail 全てのスタンプを取得します
// GetAllStampsWithThumbnail 全てのスタンプとサムネイルの有無を取得します
//
// 成功した場合、スタンプのIDでソートされた配列とnilを返します。
// DBによるエラーを返すことがあります。
Expand Down

0 comments on commit b7a434d

Please sign in to comment.