[V3-1071] Enhanced project members search to full name. (#1192)

This commit is contained in:
Bogdan Artemenko 2019-01-31 16:11:53 +02:00 committed by GitHub
parent 5e27d6ec59
commit cec2e2d0d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,7 @@ package satellitedb
import ( import (
"context" "context"
"strings"
"github.com/skyrings/skyring-common/tools/uuid" "github.com/skyrings/skyring-common/tools/uuid"
"github.com/zeebo/errs" "github.com/zeebo/errs"
@ -37,7 +38,7 @@ func (pm *projectMembers) GetByProjectID(ctx context.Context, projectID uuid.UUI
} }
var projectMembers []console.ProjectMember var projectMembers []console.ProjectMember
searchSubQuery := "%" + pagination.Search + "%" searchSubQuery := "%" + strings.Replace(pagination.Search, " ", "%", -1) + "%"
//`+getOrder(pagination.Order)+` //`+getOrder(pagination.Order)+`
// TODO: LIKE is case-sensitive postgres, however this should be case-insensitive and possibly allow typos // TODO: LIKE is case-sensitive postgres, however this should be case-insensitive and possibly allow typos
@ -47,8 +48,8 @@ func (pm *projectMembers) GetByProjectID(ctx context.Context, projectID uuid.UUI
INNER JOIN users u ON pm.member_id = u.id INNER JOIN users u ON pm.member_id = u.id
WHERE pm.project_id = ? WHERE pm.project_id = ?
AND ( u.email LIKE ? OR AND ( u.email LIKE ? OR
u.first_name LIKE ? OR u.first_name || u.last_name LIKE ? OR
u.last_name LIKE ? ) u.last_name || u.first_name LIKE ? )
ORDER BY ` + sanitizedOrderColumnName(pagination.Order) + ` ASC ORDER BY ` + sanitizedOrderColumnName(pagination.Order) + ` ASC
LIMIT ? OFFSET ? LIMIT ? OFFSET ?
`) `)