mirror of
https://github.com/sigmasternchen/threadule
synced 2025-03-15 08:09:01 +00:00
feat: account endpoint now returns threads and tweets in correct order
This commit is contained in:
parent
b61be2af7a
commit
bed63fc923
1 changed files with 7 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
|||
package data
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"threadule/backend/internal/data/models"
|
||||
)
|
||||
|
@ -8,8 +9,12 @@ import (
|
|||
func (d *Data) GetAccountsByUser(user *models.User) ([]models.Account, error) {
|
||||
var accounts []models.Account
|
||||
err := d.db.
|
||||
Preload("Threads").
|
||||
Preload("Threads.Tweets").
|
||||
Preload("Threads", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Order("scheduled_for ASC")
|
||||
}).
|
||||
Preload("Threads.Tweets", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Order("ordinal ASC")
|
||||
}).
|
||||
Where("user_id = ?", user.ID).
|
||||
Where("access_token IS NOT NULL").
|
||||
Find(&accounts).
|
||||
|
|
Loading…
Reference in a new issue