fix: address code review findings

This commit is contained in:
2026-08-19 14:02:08 +03:00
parent c2bdffb0ab
commit c3bc719878
5 changed files with 79 additions and 187 deletions

View File

@@ -25,7 +25,6 @@ type HandlerContext struct {
Redis *redis.Client
Router *routing.Graph
Yandex *yandex.Client
SearchCache *routing.SearchCacheService
Preferences *cache.Preferences
Metrics *metrics.Metrics
SearchStart time.Time
@@ -207,13 +206,14 @@ func RouteSearch(hc *HandlerContext, w http.ResponseWriter, r *http.Request) {
RankingMode: rankingMode,
}
// Determine if this is a far-term search (date is more than 7 days in the future)
// Determine if this is a far-term search (date is 7 or more days in the future)
if req.Date != "" {
requestDate, err := time.Parse("2006-01-02", req.Date)
if err == nil {
now := time.Now()
daysDiff := int(requestDate.Sub(now).Hours() / 24)
if daysDiff >= 7 {
// Check if date is 7 or more days in the future
sevenDaysLater := now.AddDate(0, 0, 7)
if !requestDate.Before(sevenDaysLater) {
opts.FarTerm = true
}
}
@@ -733,7 +733,6 @@ func NewHandlerContext(redisClient *redis.Client, router *routing.Graph, yandex
Redis: redisClient,
Router: router,
Yandex: yandex,
SearchCache: routing.NewSearchCacheService(cacheStore, yandex, m),
Preferences: cache.NewPreferences(cacheStore),
Metrics: m,
SearchStart: time.Now(),