From fbbad0616a9009fc93e09cb06545ac080e45e280 Mon Sep 17 00:00:00 2001 From: dengbiao Date: Mon, 30 Dec 2024 14:13:45 +0800 Subject: [PATCH] update --- utils/es/base.go | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/utils/es/base.go b/utils/es/base.go index 8805951..73fa7e5 100644 --- a/utils/es/base.go +++ b/utils/es/base.go @@ -18,27 +18,22 @@ func GetAppointIndexFromAlias(year string, week string) string { // GetLatestEffectiveIndexFromAlias 获取最新有效别名 // TODO::临时默认全是60分 func GetLatestEffectiveIndexFromAlias(now time.Time) string { - var esIndexName string - year, week := now.ISOWeek() if now.Weekday() > time.Wednesday || (now.Weekday() > time.Wednesday && now.Hour() > 14) { // 当前已经过了周三下午两点 返回上周蛋蛋分 - esIndexName = egg_system_rules.IntToStr(year) + egg_system_rules.IntToStr(week-1) + now = now.AddDate(0, 0, -7*2) } else { // 没过周三下午两点 返回上上周蛋蛋分 - esIndexName = egg_system_rules.IntToStr(year) + egg_system_rules.IntToStr(week-2) + now = now.AddDate(0, 0, -7*1) } - return esIndexName + year, week := now.ISOWeek() + return egg_system_rules.IntToStr(year) + egg_system_rules.IntToStr(week) } func GetLatestEffectiveIndexFromAliasForAdmin(now time.Time) string { - var esIndexName string - year, week := now.ISOWeek() - if now.Weekday() > time.Tuesday || (now.Weekday() > time.Tuesday && now.Hour() > 18) { - // 当前已经过了周三下午两点 返回本周蛋蛋分 - esIndexName = egg_system_rules.IntToStr(year) + egg_system_rules.IntToStr(week) - } else { + if !(now.Weekday() > time.Tuesday || (now.Weekday() > time.Tuesday && now.Hour() > 18)) { // 没过周三下午两点 返回上周蛋蛋分 - esIndexName = egg_system_rules.IntToStr(year) + egg_system_rules.IntToStr(week-1) + now = now.AddDate(0, 0, -7) } - return esIndexName + year, week := now.ISOWeek() + return egg_system_rules.IntToStr(year) + egg_system_rules.IntToStr(week) }