feat(postgres): added GetAllAnthroveUserIDs

This commit is contained in:
SoXX 2024-06-14 15:09:11 +02:00
parent 4cdd4450d5
commit 6268a594cf
2 changed files with 22 additions and 2 deletions

View File

@ -211,3 +211,24 @@ func GetAnthroveUser(ctx context.Context, db *gorm.DB, anthroveUserID models.Ant
return anthroveUser, nil
}
func GetAllAnthroveUserIDs(ctx context.Context, db *gorm.DB) ([]models.AnthroveUserID, error) {
var users []pgModels.User
var userIDs []models.AnthroveUserID
err := db.WithContext(ctx).Model(&pgModels.User{}).Find(&users).Error
if err != nil {
log.Error("database: failed to get all anthrove user IDs")
return nil, err
}
for _, user := range users {
userIDs = append(userIDs, models.AnthroveUserID(user.ID))
}
log.WithFields(log.Fields{
"anthrove_user_id_count": len(userIDs),
}).Trace("database: got all anthrove user IDs")
return userIDs, nil
}

View File

@ -118,8 +118,7 @@ func (p *postgresqlConnection) GetAnthroveUser(ctx context.Context, anthroveUser
}
func (p *postgresqlConnection) GetAllAnthroveUserIDs(ctx context.Context) ([]models.AnthroveUserID, error) {
//TODO implement me
panic("implement me")
return postgres.GetAllAnthroveUserIDs(ctx, p.db)
}
func (p *postgresqlConnection) GetUserFavoritePostsWithPagination(ctx context.Context, anthroveUserID models.AnthroveUserID, skip int, limit int) (*graphModels.FavoriteList, error) {