tuned default precene fetch

This commit is contained in:
Yevhen Odynets
2026-01-18 01:07:51 +02:00
parent 8eeb962016
commit 0979bf5ad8
4 changed files with 22 additions and 14 deletions

View File

@@ -13,23 +13,18 @@ import (
)
func (h *Handler) Prescene() string {
pagesToScrape := []string{"1"}
currMinute := time.Now().Minute()
levels := viper.GetInt(constant.CfgKeyLevelsToScrape)
initPage := strconv.Itoa(currMinute/(60/levels) + 1)
pagesToScrape := []string{initPage}
if levels > 1 {
var q = (60.0 / 100.0) * (100.0 / viper.GetFloat64(constant.CfgKeyLevelsToScrape))
minute := float64(time.Now().Minute())
if minute < 1 {
minute = 1
}
var q = (60.0 / 100.0) * (100.0 / float64(levels))
minute := float64(currMinute + 1)
fmt.Printf("FLOAT: %f, %f, %v\n", minute, q, math.Ceil(minute/q))
hour := time.Now().Hour()
if hour == 1 {
hour = 25
} else if hour == 0 {
hour = 1
}
hour := time.Now().Hour() + levels
page := hour * int(math.Ceil(minute/q))
pagesToScrape = append(pagesToScrape, strconv.Itoa(page))