#1290 处理action重复问题

Merged
lewis merged 1 commits from web into V20220110 2 years ago
  1. +1
    -1
      models/action.go
  2. +10
    -2
      services/socketwrap/clientManager.go

+ 1
- 1
models/action.go View File

@@ -354,7 +354,7 @@ func GetLast20PublicFeeds() ([]*Action, error) {


actions := make([]*Action, 0, 20) actions := make([]*Action, 0, 20)


if err := x.Limit(20).Desc("id").Where(cond).Find(&actions); err != nil {
if err := x.Limit(30).Desc("id").Where(cond).Find(&actions); err != nil {
return nil, fmt.Errorf("Find: %v", err) return nil, fmt.Errorf("Find: %v", err)
} }




+ 10
- 2
services/socketwrap/clientManager.go View File

@@ -26,7 +26,7 @@ func NewClientsManager() *ClientsManager {


const MaxClients = 100 const MaxClients = 100


var LastActionsQueue = NewSyncQueue(11)
var LastActionsQueue = NewSyncQueue(15)


func (h *ClientsManager) Run() { func (h *ClientsManager) Run() {
initActionQueue() initActionQueue()
@@ -75,7 +75,15 @@ func initActionQueue() {
actions, err := models.GetLast20PublicFeeds() actions, err := models.GetLast20PublicFeeds()
if err == nil { if err == nil {
for i := len(actions) - 1; i >= 0; i-- { for i := len(actions) - 1; i >= 0; i-- {
LastActionsQueue.Push(actions[i])

user, err := models.GetUserByID(actions[i].UserID)
if err == nil {
if !user.IsOrganization() {
LastActionsQueue.Push(actions[i])
}

}

} }
} }
} }

Loading…
Cancel
Save