mirror of https://gitee.com/answerdev/answer.git
feat(user): group by user info in timeline
This commit is contained in:
parent
99a61fcf7c
commit
6fa3bf0be0
|
@ -33,14 +33,12 @@ type ActObjectTimeline struct {
|
|||
RevisionID string `json:"revision_id"`
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
ActivityType string `json:"activity_type"`
|
||||
Username string `json:"username"`
|
||||
UserDisplayName string `json:"user_display_name"`
|
||||
Comment string `json:"comment"`
|
||||
ObjectID string `json:"object_id"`
|
||||
ObjectType string `json:"object_type"`
|
||||
Cancelled bool `json:"cancelled"`
|
||||
CancelledAt int64 `json:"cancelled_at"`
|
||||
UserID string `json:"id"`
|
||||
UserInfo *UserBasicInfo `json:"user_info,omitempty"`
|
||||
}
|
||||
|
||||
// ActObjectInfo act object info
|
||||
|
|
|
@ -369,6 +369,7 @@ type QuestionPageRespOperator struct {
|
|||
Username string `json:"username"`
|
||||
Rank int `json:"rank"`
|
||||
DisplayName string `json:"display_name"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
type AdminQuestionPageReq struct {
|
||||
|
|
|
@ -91,6 +91,7 @@ func (as *ActivityService) GetObjectTimeline(ctx context.Context, req *schema.Ge
|
|||
CreatedAt: act.CreatedAt.Unix(),
|
||||
Cancelled: act.Cancelled == entity.ActivityCancelled,
|
||||
ObjectID: act.ObjectID,
|
||||
UserInfo: &schema.UserBasicInfo{},
|
||||
}
|
||||
item.ObjectType, _ = obj.GetObjectTypeStrByObjectID(act.ObjectID)
|
||||
if item.Cancelled {
|
||||
|
@ -120,13 +121,13 @@ func (as *ActivityService) GetObjectTimeline(ctx context.Context, req *schema.Ge
|
|||
|
||||
// if activity is down vote, only admin can see who does it.
|
||||
if item.ActivityType == constant.ActDownVote && !req.IsAdmin {
|
||||
item.Username = "N/A"
|
||||
item.UserDisplayName = "N/A"
|
||||
item.UserInfo.Username = "N/A"
|
||||
item.UserInfo.DisplayName = "N/A"
|
||||
} else {
|
||||
if act.TriggerUserID > 0 {
|
||||
item.UserID = fmt.Sprintf("%d", act.TriggerUserID)
|
||||
item.UserInfo.ID = fmt.Sprintf("%d", act.TriggerUserID)
|
||||
} else {
|
||||
item.UserID = act.UserID
|
||||
item.UserInfo.ID = act.UserID
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -209,10 +210,10 @@ func (as *ActivityService) formatTimelineUserInfo(ctx context.Context, timeline
|
|||
userExist := make(map[string]bool)
|
||||
userIDs := make([]string, 0)
|
||||
for _, info := range timeline {
|
||||
if len(info.UserID) == 0 || userExist[info.UserID] {
|
||||
if len(info.UserInfo.ID) == 0 || userExist[info.UserInfo.ID] {
|
||||
continue
|
||||
}
|
||||
userIDs = append(userIDs, info.UserID)
|
||||
userIDs = append(userIDs, info.UserInfo.ID)
|
||||
}
|
||||
if len(userIDs) == 0 {
|
||||
return
|
||||
|
@ -223,13 +224,10 @@ func (as *ActivityService) formatTimelineUserInfo(ctx context.Context, timeline
|
|||
return
|
||||
}
|
||||
for _, info := range timeline {
|
||||
if len(info.UserID) == 0 {
|
||||
if len(info.UserInfo.ID) == 0 {
|
||||
continue
|
||||
}
|
||||
if userInfo, ok := userInfoMapping[info.UserID]; ok {
|
||||
info.Username = userInfo.Username
|
||||
info.UserDisplayName = userInfo.DisplayName
|
||||
}
|
||||
info.UserInfo = userInfoMapping[info.UserInfo.ID]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -387,6 +387,7 @@ func (qs *QuestionCommon) FormatQuestionsPage(
|
|||
item.Operator.DisplayName = userInfo.DisplayName
|
||||
item.Operator.Username = userInfo.Username
|
||||
item.Operator.Rank = userInfo.Rank
|
||||
item.Operator.Status = userInfo.Status
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue