add load more command

This commit is contained in:
2026-02-12 17:52:32 +03:00
parent 4e1d1ca35f
commit a058b622e3
7 changed files with 161 additions and 33 deletions
+30
View File
@@ -68,3 +68,33 @@ func (s *Service) GetTodayMemory(ctx context.Context) (*search.Memory, error) {
return mem, nil
}
// LoadNewMemory selects a new memory ignoring the cache, records the show,
// and updates the cache so that subsequent GetTodayMemory calls return it.
func (s *Service) LoadNewMemory(ctx context.Context) (*search.Memory, error) {
today := time.Now().In(s.loc)
dayKey := today.Format("2006-01-02")
s.logger.Info("loading additional memory", "date", dayKey)
mem, err := s.selector.Select(ctx, today)
if err != nil {
return nil, err
}
if mem == nil {
s.logger.Warn("no memory found for load more")
return nil, nil
}
if err := s.store.RecordShow(ctx, mem.Memo.Name, mem.Tier); err != nil {
s.logger.Error("failed to record show", "error", err)
}
s.mu.Lock()
s.cacheDay = dayKey
s.cached = mem
s.mu.Unlock()
return mem, nil
}