Skip to content

Commit

Permalink
Merge pull request #9 from opensourceways/20241010
Browse files Browse the repository at this point in the history
sql优化
  • Loading branch information
shishupei authored Oct 16, 2024
2 parents 60d26be + 4fa2fff commit bb2a2c7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion message/infrastructure/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ func (s *messageAdapter) GetInnerMessageQuick(cmd CmdToGetInnerMessageQuick,
query.Count(&Count)

var response []MessageListDAO
if result := query.Debug().Limit(cmd.CountPerPage).Offset(offsetNum).
if result := query.Limit(cmd.CountPerPage).Offset(offsetNum).
Order("cloud_event_message.time DESC").
Scan(&response); result.Error != nil {
return []MessageListDAO{}, 0, xerrors.Errorf("get inner message failed, err:%v",
Expand Down
10 changes: 5 additions & 5 deletions message/infrastructure/subscribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ func (ctl *messageSubscribeAdapter) GetSubsConfig(userName string) ([]MessageSub
var response []MessageSubscribeDAOWithPushConfig

query := postgresql.DB().Table("message_center.subscribe_config").
Select("subscribe_config.*, push_config.need_mail").
Joins("JOIN message_center.push_config ON subscribe_config.id = push_config.subscribe_id").
Where(gorm.Expr("subscribe_config.is_deleted = ?", false)).
Where("subscribe_config.user_name = ?", userName)
Select("subscribe_config.*, (SELECT push_config.need_mail FROM message_center."+
"push_config WHERE push_config.subscribe_id = subscribe_config.id LIMIT 1) AS need_mail").
Where("subscribe_config.is_deleted = ? AND subscribe_config.user_name = ?",
false, userName)

var Count int64
query.Count(&Count)
if result := query.Order("subscribe_config.id").Find(&response); result.Error != nil {
if result := query.Debug().Order("subscribe_config.id").Find(&response); result.Error != nil {
return []MessageSubscribeDAOWithPushConfig{}, 0, xerrors.Errorf("查询失败")
}

Expand Down

0 comments on commit bb2a2c7

Please sign in to comment.