otto 8 months ago
parent
commit
7d42712db2
  1. 2
      go.mod
  2. 26
      task/task.go

2
go.mod

@ -3,7 +3,7 @@ module git.gz.internal.jumaiyx.cn/job/hotspot-clear
go 1.20 go 1.20
require ( require (
git.gz.internal.jumaiyx.cn/jm/jmproto v0.0.0-20240321070012-9ad2cc15ec1c git.gz.internal.jumaiyx.cn/jm/jmproto v0.0.0-20240415093446-0004fca23b7b
git.gz.internal.jumaiyx.cn/pkg/client v0.0.0-20231123090823-91017d7a1a1e git.gz.internal.jumaiyx.cn/pkg/client v0.0.0-20231123090823-91017d7a1a1e
git.gz.internal.jumaiyx.cn/pkg/config/v2 v2.0.0-20240312130125-0f8bbcc94011 git.gz.internal.jumaiyx.cn/pkg/config/v2 v2.0.0-20240312130125-0f8bbcc94011
git.gz.internal.jumaiyx.cn/pkg/k8s-client/v2 v2.0.3-0.20240229083126-a1abe7ddc19f git.gz.internal.jumaiyx.cn/pkg/k8s-client/v2 v2.0.3-0.20240229083126-a1abe7ddc19f

26
task/task.go

@ -2,6 +2,7 @@ package task
import ( import (
"context" "context"
livev1 "git.gz.internal.jumaiyx.cn/jm/jmproto/live/v1"
v2 "git.gz.internal.jumaiyx.cn/jm/jmproto/room/v2" v2 "git.gz.internal.jumaiyx.cn/jm/jmproto/room/v2"
"git.gz.internal.jumaiyx.cn/pkg/client" "git.gz.internal.jumaiyx.cn/pkg/client"
configv2 "git.gz.internal.jumaiyx.cn/pkg/config/v2" configv2 "git.gz.internal.jumaiyx.cn/pkg/config/v2"
@ -79,14 +80,35 @@ func task(start, end int64) error {
if err != nil { if err != nil {
return err return err
} }
liveClient, liveClientClose, err := client.GetLiveClient(context.Background())
if err != nil {
return err
}
defer func() { _ = liveClientClose() }()
onlineTotalResp, err := liveClient.GetLiveOnlineTotal(context.Background(), &livev1.GetLiveOnlineTotalReq{
RoomIdList: ids,
})
if err != nil {
return err
}
roomClient, roomClientClose, err := client.GetRoomClientV2(context.Background()) roomClient, roomClientClose, err := client.GetRoomClientV2(context.Background())
if err != nil { if err != nil {
return err return err
} }
defer func() { _ = roomClientClose() }() defer func() { _ = roomClientClose() }()
onlineMap := onlineTotalResp.Items
var items []*v2.IncrRoomHotspotReq_Item
for _, id := range ids {
online := onlineMap[id]
items = append(items, &v2.IncrRoomHotspotReq_Item{
RoomId: id,
HotValue: int32(online) * 10,
})
}
_, err = roomClient.IncrRoomHotspot(context.Background(), &v2.IncrRoomHotspotReq{ _, err = roomClient.IncrRoomHotspot(context.Background(), &v2.IncrRoomHotspotReq{
RoomIdList: ids, Items: items,
HotValue: 0,
}) })
if err != nil { if err != nil {
return err return err

Loading…
Cancel
Save