Replace db count query in user signup process (#18072)

Этот коммит содержится в:
Claudio Costa
2021-08-12 11:23:21 +02:00
коммит произвёл GitHub
родитель d3973557fc
Коммит bd65e8daf9
12 изменённых файлов: 126 добавлений и 9 удалений

Просмотреть файл

@@ -2002,3 +2002,13 @@ func (us SqlUserStore) GetKnownUsers(userId string) ([]string, error) {
return userIds, nil
}
// IsEmpty returns whether or not the Users table is empty.
func (us SqlUserStore) IsEmpty() (bool, error) {
var hasRows bool
err := us.GetReplica().SelectOne(&hasRows, `SELECT EXISTS (SELECT 1 FROM Users)`)
if err != nil {
return false, errors.Wrap(err, "failed to check if table is empty")
}
return !hasRows, nil
}