Skip to content

Commit

Permalink
feat: performance optimization - user
Browse files Browse the repository at this point in the history
  • Loading branch information
teamgramio committed Sep 5, 2022
1 parent 3d4de6b commit eb72e2f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ import (
// UserGetImmutableUser
// user.getImmutableUser id:long = ImmutableUser;
func (c *UserCore) UserGetImmutableUser(in *user.TLUserGetImmutableUser) (*user.ImmutableUser, error) {
imUser, err := c.getImmutableUser(in.GetId(), false, false)
imUser, err := c.getImmutableUser(in.GetId(), false)
if err != nil {
return nil, err
}

return imUser, nil
}

func (c *UserCore) getImmutableUser(id int64, contacts, privacy bool) (*user.ImmutableUser, error) {
func (c *UserCore) getImmutableUser(id int64, privacy bool, contacts ...int64) (*user.ImmutableUser, error) {
userData := c.svcCtx.Dao.GetUserData(c.ctx, id)

// userDO, _ := c.svcCtx.Dao.UsersDAO.SelectById(c.ctx, in.Id)
Expand All @@ -53,10 +53,8 @@ func (c *UserCore) getImmutableUser(id int64, contacts, privacy bool) (*user.Imm
}
},
func() {
if contacts {
// TODO: aaa
immutableUser.Contacts = c.svcCtx.Dao.GetUserContactList(c.ctx, id)
}
// TODO: aaa
immutableUser.Contacts = c.svcCtx.Dao.GetUserContactListByIdList(c.ctx, id, contacts...)
},
func() {
if privacy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (c *UserCore) UserGetMutableUsers(in *user.TLUserGetMutableUsers) (*user.Ve
if len(in.Id) == 0 {
return vUser, nil
} else if len(in.Id) == 1 {
immutableUser, _ := c.getImmutableUser(in.Id[0], false, false)
immutableUser, _ := c.getImmutableUser(in.Id[0], false)
if immutableUser != nil {
vUser.Datas = append(vUser.Datas, immutableUser)
}
Expand All @@ -42,7 +42,7 @@ func (c *UserCore) UserGetMutableUsers(in *user.TLUserGetMutableUsers) (*user.Ve
},
func(item interface{}) {
idx := item.(int)
immutableUser, _ := c.getImmutableUser(in.Id[idx], true, true)
immutableUser, _ := c.getImmutableUser(in.Id[idx], true, in.Id...)
mutableUsers[idx] = immutableUser
})

Expand Down

0 comments on commit eb72e2f

Please sign in to comment.