From 992412264884aab71862c18d1c25077cc81798d5 Mon Sep 17 00:00:00 2001 From: Gusted Date: Thu, 13 Jan 2022 18:58:26 +0100 Subject: [PATCH 1/3] Change TODO --- models/user/search.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/user/search.go b/models/user/search.go index 5c37bb996172e..93ed81cef710e 100644 --- a/models/user/search.go +++ b/models/user/search.go @@ -107,7 +107,7 @@ func (opts *SearchUserOptions) toSearchQueryBase() *xorm.Session { } // 2fa filter uses LEFT JOIN to check whether a user has a 2fa record - // TODO: bad performance here, maybe there will be a column "is_2fa_enabled" in the future + // TODO: Add a "is_2fa_enabled" column to the user' setting table. if opts.IsTwoFactorEnabled.IsTrue() { cond = cond.And(builder.Expr("two_factor.uid IS NOT NULL")) } else { From 2cca4f4978bf13c13a9ba8a2b706a761366492be Mon Sep 17 00:00:00 2001 From: Gusted Date: Thu, 13 Jan 2022 19:52:46 +0000 Subject: [PATCH 2/3] Update models/user/search.go Co-authored-by: wxiaoguang --- models/user/search.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/models/user/search.go b/models/user/search.go index 93ed81cef710e..be2a21536c0dc 100644 --- a/models/user/search.go +++ b/models/user/search.go @@ -107,7 +107,9 @@ func (opts *SearchUserOptions) toSearchQueryBase() *xorm.Session { } // 2fa filter uses LEFT JOIN to check whether a user has a 2fa record - // TODO: Add a "is_2fa_enabled" column to the user' setting table. + // While using LEFT JOIN, sometimes the performance might not be good, but it won't be a problem now, such SQL is seldom executed. + // There are some possible methods to refactor this SQL in future when we really need to optimize the performance (but not now): + // (1) add a column in user table (2) add a setting value in user_setting table (3) use text indexer (bleve/elasticsearch) if opts.IsTwoFactorEnabled.IsTrue() { cond = cond.And(builder.Expr("two_factor.uid IS NOT NULL")) } else { From 4d231f1fe21b98d79b94d4a7a1b914e64e12bc9f Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Fri, 14 Jan 2022 03:54:37 +0800 Subject: [PATCH 3/3] Update search.go --- models/user/search.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/user/search.go b/models/user/search.go index be2a21536c0dc..fac180529ffaf 100644 --- a/models/user/search.go +++ b/models/user/search.go @@ -109,7 +109,7 @@ func (opts *SearchUserOptions) toSearchQueryBase() *xorm.Session { // 2fa filter uses LEFT JOIN to check whether a user has a 2fa record // While using LEFT JOIN, sometimes the performance might not be good, but it won't be a problem now, such SQL is seldom executed. // There are some possible methods to refactor this SQL in future when we really need to optimize the performance (but not now): - // (1) add a column in user table (2) add a setting value in user_setting table (3) use text indexer (bleve/elasticsearch) + // (1) add a column in user table (2) add a setting value in user_setting table (3) use search engines (bleve/elasticsearch) if opts.IsTwoFactorEnabled.IsTrue() { cond = cond.And(builder.Expr("two_factor.uid IS NOT NULL")) } else {