Skip to content

Commit

Permalink
refactor(backend): change order of funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnisDa committed Oct 16, 2023
1 parent cd2015f commit 611556f
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions backend/persistence/user_persister.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,6 @@ func NewUserPersister(db *pop.Connection) UserPersister {
return &userPersister{db: db}
}

func (p *userPersister) All() ([]models.User, error) {
users := []models.User{}
err := p.db.EagerPreload("Emails", "Emails.PrimaryEmail", "Emails.Identity", "WebauthnCredentials").All(&users)
if err != nil && errors.Is(err, sql.ErrNoRows) {
return users, nil
}
if err != nil {
return nil, fmt.Errorf("failed to fetch users: %w", err)
}

return users, nil
}

func (p *userPersister) Get(id uuid.UUID) (*models.User, error) {
user := models.User{}
err := p.db.EagerPreload("Emails", "Emails.PrimaryEmail", "Emails.Identity", "WebauthnCredentials").Find(&user, id)
Expand Down Expand Up @@ -126,6 +113,19 @@ func (p *userPersister) List(page int, perPage int, userId uuid.UUID, email stri
return users, nil
}

func (p *userPersister) All() ([]models.User, error) {
users := []models.User{}
err := p.db.EagerPreload("Emails", "Emails.PrimaryEmail", "Emails.Identity", "WebauthnCredentials").All(&users)
if err != nil && errors.Is(err, sql.ErrNoRows) {
return users, nil
}
if err != nil {
return nil, fmt.Errorf("failed to fetch users: %w", err)
}

return users, nil
}

func (p *userPersister) Count(userId uuid.UUID, email string) (int, error) {
query := p.db.
Q().
Expand Down

0 comments on commit 611556f

Please sign in to comment.