mirror of
https://github.com/grafana/grafana.git
synced 2025-01-08 07:03:11 -06:00
services/sqlstore: Order results in UserSearch by username/email (#23328)
* services/sqlstore: Order results in UserSearch by username/email * Add index (login,email) on user table
This commit is contained in:
parent
b86789c66b
commit
0fd6edab64
@ -122,6 +122,10 @@ func addUserMigrations(mg *Migrator) {
|
||||
mg.AddMigration("Add is_disabled column to user", NewAddColumnMigration(userV2, &Column{
|
||||
Name: "is_disabled", Type: DB_Bool, Nullable: false, Default: "0",
|
||||
}))
|
||||
|
||||
mg.AddMigration("Add index user.login/user.email", NewAddIndexMigration(userV2, &Index{
|
||||
Cols: []string{"login", "email"},
|
||||
}))
|
||||
}
|
||||
|
||||
type AddMissingUserSaltAndRandsMigration struct {
|
||||
|
@ -68,7 +68,6 @@ func (ss *SqlStore) Init() error {
|
||||
ss.readConfig()
|
||||
|
||||
engine, err := ss.getEngine()
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("Fail to connect to database: %v", err)
|
||||
}
|
||||
@ -232,7 +231,6 @@ func (ss *SqlStore) buildConnectionString() (string, error) {
|
||||
|
||||
func (ss *SqlStore) getEngine() (*xorm.Engine, error) {
|
||||
connectionString, err := ss.buildConnectionString()
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -454,7 +454,7 @@ func SearchUsers(query *models.SearchUsersQuery) error {
|
||||
offset := query.Limit * (query.Page - 1)
|
||||
sess.Limit(query.Limit, offset)
|
||||
sess.Cols("u.id", "u.email", "u.name", "u.login", "u.is_admin", "u.is_disabled", "u.last_seen_at", "user_auth.auth_module")
|
||||
sess.OrderBy("u.id")
|
||||
sess.Asc("u.login", "u.email")
|
||||
if err := sess.Find(&query.Result.Users); err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user