MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / GetProjectUserList

Function GetProjectUserList

cmd/cql-proxy/model/project_user.go:164–203  ·  view source on GitHub ↗

GetProjectUserList provide search and paging of project user list.

(db *gorp.DbMap, searchTerm string, showOnlyEnabled bool, offset int64, limit int64)

Source from the content-addressed store, hash-verified

162
163// GetProjectUserList provide search and paging of project user list.
164func GetProjectUserList(db *gorp.DbMap, searchTerm string, showOnlyEnabled bool, offset int64, limit int64) (
165 users []*ProjectUser, total int64, err error) {
166 var (
167 sql = `SELECT * FROM "____user" WHERE 1=1 `
168 args []interface{}
169 totalSQL = `SELECT COUNT(1) AS "cnt" FROM "____user" WHERE 1=1 `
170 totalArgs []interface{}
171 )
172
173 if showOnlyEnabled {
174 sql += ` AND "state" = ? `
175 totalSQL += ` AND "state" = ? `
176 args = append(args, ProjectUserStateEnabled)
177 totalArgs = append(totalArgs, ProjectUserStateEnabled)
178 }
179
180 if searchTerm != "" {
181 sql += ` AND ("name" LIKE ("%" || ? || "%") OR "email" LIKE ("%" || ? || "%"))`
182 args = append(args, searchTerm, searchTerm)
183 totalSQL += ` AND ("name" LIKE ("%" || ? || "%") OR "email" LIKE ("%" || ? || "%"))`
184 totalArgs = append(totalArgs, searchTerm, searchTerm)
185 }
186
187 sql += ` ORDER BY "id" LIMIT ?, ?`
188 args = append(args, offset, limit)
189
190 total, err = db.SelectInt(totalSQL, totalArgs...)
191 if err != nil {
192 err = errors.Wrapf(err, "get user list total count failed")
193 return
194 }
195
196 _, err = db.Select(&users, sql, args...)
197 if err != nil {
198 err = errors.Wrapf(err, "get user list failed")
199 return
200 }
201
202 return
203}
204
205// EnsureProjectUser add/update user info to project database.s
206func EnsureProjectUser(db *gorp.DbMap, provider string,

Callers 1

projectUserListFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected