fix: preload uploads

This commit is contained in:
Derrick Hammer 2024-01-24 12:47:20 -05:00
parent 60c905181c
commit 9b655b4a70
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 6 additions and 1 deletions

View File

@ -116,7 +116,12 @@ func (s AccountServiceImpl) LoginPubkey(pubkey string) (string, error) {
func (s AccountServiceImpl) AccountPins(id uint64, createdAfter uint64) ([]models.Pin, error) { func (s AccountServiceImpl) AccountPins(id uint64, createdAfter uint64) ([]models.Pin, error) {
var pins []models.Pin var pins []models.Pin
result := s.portal.Database().Model(&models.Pin{}).Where(&models.Pin{UserID: uint(id)}).Where("created_at > ?", createdAfter).Order("created_at desc").Find(&pins) result := s.portal.Database().Model(&models.Pin{}).
Preload("Upload"). // Preload the related Upload for each Pin
Where(&models.Pin{UserID: uint(id)}).
Where("created_at > ?", createdAfter).
Order("created_at desc").
Find(&pins)
if result.Error != nil { if result.Error != nil {
return nil, result.Error return nil, result.Error