chore: refine checkTemp
This commit is contained in:
parent
7ab409403f
commit
dae57540e3
@ -19,6 +19,7 @@ import (
|
||||
|
||||
const (
|
||||
TenYear = 3153600000
|
||||
OneMonth = OneDay * 30
|
||||
OneDay = 86400
|
||||
OneHour = 3600
|
||||
TenMinutes = 600
|
||||
@ -218,14 +219,12 @@ func processorLoop(ctx context.Context, db db, fetch *pool[*Feed, *Response]) {
|
||||
|
||||
func checkTemp(twts types.Twts) int {
|
||||
if len(twts) < 5 {
|
||||
return OneDay
|
||||
return 7*OneDay
|
||||
}
|
||||
sort.Sort(sort.Reverse(twts))
|
||||
sort.Sort(twts)
|
||||
|
||||
now := time.Now()
|
||||
|
||||
since_first := now.Sub(twts[0].Created())
|
||||
since_fifth := now.Sub(twts[4].Created())
|
||||
since_first := -time.Until(twts[0].Created())
|
||||
since_fifth := -time.Until(twts[4].Created())
|
||||
|
||||
if since_first < 2 * time.Hour || since_fifth < 8 * time.Hour {
|
||||
return TwoMinutes
|
||||
@ -236,8 +235,24 @@ func checkTemp(twts types.Twts) int {
|
||||
}
|
||||
|
||||
if since_first < 8 * time.Hour || since_fifth < 32 * time.Hour{
|
||||
return TenMinutes
|
||||
return 2*TenMinutes
|
||||
}
|
||||
|
||||
if since_first < 16 * time.Hour || since_fifth < 64 * time.Hour{
|
||||
return 4*TenMinutes
|
||||
}
|
||||
|
||||
if since_first < 24 * time.Hour || since_fifth < 128 * time.Hour{
|
||||
return OneDay
|
||||
}
|
||||
|
||||
if since_first < 48 * time.Hour || since_fifth < 256 * time.Hour{
|
||||
return 2*OneDay
|
||||
}
|
||||
|
||||
if since_first < 96 * time.Hour || since_fifth < 512 * time.Hour{
|
||||
return 7*OneDay
|
||||
}
|
||||
|
||||
return OneMonth
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user