by Robin at 20240412

This commit is contained in:
Leufolium 2024-04-12 23:02:55 +08:00
parent 156cc92de9
commit e986f9ba07
2 changed files with 15 additions and 1 deletions

View File

@ -214,3 +214,8 @@ const (
IsHeaded_No = 0 //否
IsHeaded_Yes = 1 //是
)
// 从未更新的时间跨度
const (
DaysElapsedSinceTheLastZonesUpdate_Never = -1
)

View File

@ -763,8 +763,17 @@ func (s *Service) utilGetStreamerExtMapByMids(ctx *gin.Context, mids []int64, op
streamerExt.CopyZones(zonesMap[mid])
// 计算空间更新时间距离现在时间跨度
nowTime := time.Now()
lastZoneMomentCt := int64(0)
for _, zone := range zonesMap[mid] {
lastZoneMomentCreateDay := util.GetDayStartTimeStamp(time.Unix(util.DerefInt64(zone.LastZoneMomentCt), 0))
if util.DerefInt64(zone.LastZoneMomentCt) > lastZoneMomentCt {
lastZoneMomentCt = util.DerefInt64(zone.LastZoneMomentCt)
}
}
if lastZoneMomentCt == 0 {
streamerExt.SetIsActiveWithinAWeek(consts.ZoneIsActiveWithinAWeek_No)
streamerExt.SetDaysElapsedSinceTheLastZonesUpdate(consts.DaysElapsedSinceTheLastZonesUpdate_Never)
} else {
lastZoneMomentCreateDay := util.GetDayStartTimeStamp(time.Unix(lastZoneMomentCt, 0))
today := util.GetDayStartTimeStamp(nowTime)
daysElapsedSinceTheLastZonesUpdate := (today - lastZoneMomentCreateDay) / int64(86400) // 24 * 60 * 60 = 86400秒
streamerExt.SetDaysElapsedSinceTheLastZonesUpdate(daysElapsedSinceTheLastZonesUpdate)