move + restructure processor

This commit is contained in:
tsmethurst 2021-06-29 14:36:16 +02:00
commit 4c09baf798
37 changed files with 1363 additions and 950 deletions

View file

@ -2,6 +2,7 @@ package pg
import (
"github.com/go-pg/pg/v10"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
)
@ -50,3 +51,31 @@ func (ps *postgresService) GetDomainCountForInstance(domain string) (int, error)
return q.Count()
}
func (ps *postgresService) GetAccountsForInstance(domain string, maxID string, limit int) ([]*gtsmodel.Account, error) {
accounts := []*gtsmodel.Account{}
q := ps.conn.Model(&accounts).Where("domain = ?", domain).Order("id DESC")
if maxID != "" {
q = q.Where("id < ?", maxID)
}
if limit > 0 {
q = q.Limit(limit)
}
err := q.Select()
if err != nil {
if err == pg.ErrNoRows {
return nil, db.ErrNoEntries{}
}
return nil, err
}
if len(accounts) == 0 {
return nil, db.ErrNoEntries{}
}
return accounts, nil
}