Merge branch 'master' into MM-45118_my_top_dms
Этот коммит содержится в:
@@ -784,6 +784,13 @@ func (s *SqlPostStore) Get(ctx context.Context, id string, opts model.GetPostsOp
|
||||
}
|
||||
|
||||
for _, p := range posts {
|
||||
if p.Id == id {
|
||||
// Based on the conditions above such as sq.Or{ sq.Eq{"p.Id": rootId}, sq.Eq{"p.RootId": rootId}, }
|
||||
// posts may contain the "id" post which has already been fetched and added in the "pl"
|
||||
// So, skip the "id" to avoid duplicate entry of the post
|
||||
continue
|
||||
}
|
||||
|
||||
pl.AddPost(p)
|
||||
pl.AddOrder(p.Id)
|
||||
}
|
||||
@@ -2188,7 +2195,7 @@ func (s *SqlPostStore) AnalyticsPostCountsByDay(options *model.AnalyticsPostCoun
|
||||
|
||||
func (s *SqlPostStore) AnalyticsPostCount(options *model.PostCountOptions) (int64, error) {
|
||||
query := s.getQueryBuilder().
|
||||
Select("COUNT(p.Id) AS Value").
|
||||
Select("COUNT(*) AS Value").
|
||||
From("Posts p")
|
||||
|
||||
if options.TeamId != "" {
|
||||
@@ -2840,8 +2847,23 @@ func (s *SqlPostStore) updateThreadAfterReplyDeletion(transaction *sqlxTxWrapper
|
||||
}
|
||||
}
|
||||
|
||||
lastReplyAtSubquery := sq.Select("COALESCE(MAX(CreateAt), 0)").
|
||||
From("Posts").
|
||||
Where(sq.Eq{
|
||||
"RootId": rootId,
|
||||
"DeleteAt": 0,
|
||||
})
|
||||
|
||||
lastReplyCountSubquery := sq.Select("Count(*)").
|
||||
From("Posts").
|
||||
Where(sq.Eq{
|
||||
"RootId": rootId,
|
||||
"DeleteAt": 0,
|
||||
})
|
||||
|
||||
updateQueryString, updateArgs, err := updateQuery.
|
||||
Set("ReplyCount", sq.Expr("ReplyCount - 1")).
|
||||
Set("LastReplyAt", lastReplyAtSubquery).
|
||||
Set("ReplyCount", lastReplyCountSubquery).
|
||||
Where(sq.And{
|
||||
sq.Eq{"PostId": rootId},
|
||||
sq.Gt{"ReplyCount": 0},
|
||||
|
||||
@@ -1500,17 +1500,20 @@ func generateSearchQuery(query sq.SelectBuilder, terms []string, fields []string
|
||||
for _, term := range terms {
|
||||
searchFields := []string{}
|
||||
termArgs := []any{}
|
||||
var dbSpecificTerm string
|
||||
|
||||
for _, field := range fields {
|
||||
if isPostgreSQL {
|
||||
searchFields = append(searchFields, fmt.Sprintf("lower(%s) LIKE lower(?) escape '*' ", field))
|
||||
searchFields = append(searchFields, fmt.Sprintf("to_tsvector(lower(%[1]s)) @@ to_tsquery(concat(lower(?),':*'))", field))
|
||||
dbSpecificTerm = strings.TrimLeft(term, "@")
|
||||
} else {
|
||||
searchFields = append(searchFields, fmt.Sprintf("%s LIKE ? escape '*' ", field))
|
||||
dbSpecificTerm = fmt.Sprintf("%s%%", strings.TrimLeft(term, "@"))
|
||||
}
|
||||
termArgs = append(termArgs, fmt.Sprintf("%s%%", strings.TrimLeft(term, "@")))
|
||||
termArgs = append(termArgs, dbSpecificTerm)
|
||||
}
|
||||
query = query.Where(fmt.Sprintf("(%s)", strings.Join(searchFields, " OR ")), termArgs...)
|
||||
}
|
||||
|
||||
return query
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user