mirror of
https://github.com/SigNoz/signoz.git
synced 2025-12-22 01:46:39 +00:00
* chore: update auth * chore: password changes * chore: make changes in oss code * chore: login * chore: get to a running state * fix: migration inital commit * fix: signoz cloud intgtn tests * fix: minor fixes * chore: sso code fixed with org domain * fix: tests * fix: ee auth api's * fix: changes in name * fix: return user in login api * fix: address comments * fix: validate password * fix: handle get domain by email properly * fix: move authomain to usermodule * fix: use displayname instead of hname * fix: rename back endpoints * fix: update telemetry * fix: correct errors * fix: test and fix the invite endpoints * fix: delete all things related to user in store * fix: address issues * fix: ee delete invite * fix: rename func * fix: update user and update role * fix: update role * fix: login and invite changes * fix: return org name in users response * fix: update user role * fix: nil check * fix: getinvite and update role * fix: sso * fix: getinvite use sso ctx * fix: use correct sourceurl * fix: getsourceurl from req payload * fix: update created_at * fix: fix reset password * fix: sso signup and token password change * fix: don't delete last admin * fix: reset password and migration * fix: migration * fix: reset password for sso users * fix: clean up invite * fix: migration * fix: update claims and store code * fix: use correct error * fix: proper nil checks * fix: make migration multitenant * fix: address comments * fix: minor fixes * fix: test * fix: rename reset password --------- Co-authored-by: Vikrant Gupta <vikrant@signoz.io>
47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
package telemetry
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/SigNoz/signoz/pkg/errors"
|
|
"github.com/SigNoz/signoz/pkg/sqlstore"
|
|
"github.com/SigNoz/signoz/pkg/types"
|
|
)
|
|
|
|
type TelemetryUser struct {
|
|
types.User
|
|
Organization string `json:"organization"`
|
|
}
|
|
|
|
func GetUsers(ctx context.Context, sqlstore sqlstore.SQLStore) ([]TelemetryUser, error) {
|
|
return GetUsersWithOpts(ctx, 0, sqlstore)
|
|
}
|
|
|
|
func GetUserCount(ctx context.Context, sqlstore sqlstore.SQLStore) (int, error) {
|
|
users, err := GetUsersWithOpts(ctx, 0, sqlstore)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
return len(users), nil
|
|
}
|
|
|
|
// GetUsersWithOpts fetches users and supports additional search options
|
|
func GetUsersWithOpts(ctx context.Context, limit int, sqlstore sqlstore.SQLStore) ([]TelemetryUser, error) {
|
|
users := []TelemetryUser{}
|
|
|
|
query := sqlstore.BunDB().NewSelect().
|
|
Table("user").
|
|
Column("user.id", "user.display_name", "user.email", "user.created_at", "user.org_id").
|
|
ColumnExpr("o.display_name as organization").
|
|
Join("JOIN organizations o ON o.id = user.org_id")
|
|
|
|
if limit > 0 {
|
|
query.Limit(limit)
|
|
}
|
|
err := query.Scan(ctx, &users)
|
|
if err != nil {
|
|
return nil, errors.WrapNotFoundf(err, errors.CodeNotFound, "failed to get users")
|
|
}
|
|
return users, nil
|
|
}
|