🐛 Fix querying attachments by usage
This commit is contained in:
parent
168c089456
commit
f5732726ed
@ -16,7 +16,7 @@ func listAttachment(c *fiber.Ctx) error {
|
|||||||
take = 100
|
take = 100
|
||||||
}
|
}
|
||||||
|
|
||||||
tx := database.C
|
tx := database.C.Order("created_at DESC")
|
||||||
|
|
||||||
if len(c.Query("author")) > 0 {
|
if len(c.Query("author")) > 0 {
|
||||||
var author models.Account
|
var author models.Account
|
||||||
@ -27,8 +27,8 @@ func listAttachment(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if usage := strings.Split(c.Query("usage"), " "); len(usage) > 0 {
|
if usage := c.Query("usage"); len(usage) > 0 {
|
||||||
tx = tx.Where("usage IN ?", usage)
|
tx = tx.Where("usage IN ?", strings.Split(usage, " "))
|
||||||
}
|
}
|
||||||
|
|
||||||
var count int64
|
var count int64
|
||||||
@ -37,7 +37,7 @@ func listAttachment(c *fiber.Ctx) error {
|
|||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||||
}
|
}
|
||||||
var attachments []models.Attachment
|
var attachments []models.Attachment
|
||||||
if err := tx.Order("created_at DESC").Offset(offset).Limit(take).Find(&attachments).Error; err != nil {
|
if err := tx.Offset(offset).Limit(take).Find(&attachments).Error; err != nil {
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user