✨ Preload thumbnail, compressed
This commit is contained in:
parent
845894f12c
commit
0c33c2d86c
@ -84,7 +84,10 @@ func listAttachment(c *fiber.Ctx) error {
|
||||
|
||||
if needQuery {
|
||||
var out []models.Attachment
|
||||
if err := tx.Offset(offset).Limit(take).Find(&out).Error; err != nil {
|
||||
if err := tx.
|
||||
Offset(offset).Limit(take).
|
||||
Preload("Thumbnail").Preload("Compressed").
|
||||
Find(&out).Error; err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,8 @@ func GetAttachmentByID(id uint) (models.Attachment, error) {
|
||||
if err := database.C.
|
||||
Where("id = ?", id).
|
||||
Preload("Pool").
|
||||
Preload("Thumbnail").
|
||||
Preload("Compressed").
|
||||
First(&attachment).Error; err != nil {
|
||||
return attachment, err
|
||||
} else {
|
||||
@ -58,7 +60,11 @@ func GetAttachmentByRID(rid string) (models.Attachment, error) {
|
||||
var attachment models.Attachment
|
||||
if err := database.C.Where(models.Attachment{
|
||||
Rid: rid,
|
||||
}).Preload("Pool").First(&attachment).Error; err != nil {
|
||||
}).
|
||||
Preload("Pool").
|
||||
Preload("Thumbnail").
|
||||
Preload("Compressed").
|
||||
First(&attachment).Error; err != nil {
|
||||
return attachment, err
|
||||
} else {
|
||||
CacheAttachment(attachment)
|
||||
|
Loading…
Reference in New Issue
Block a user