feat: add settings to chose timzone and add markdown readability on main page

This commit is contained in:
2026-04-20 08:22:47 +02:00
parent 71513ea62c
commit 8a0edc3d59
7 changed files with 87 additions and 16 deletions

View File

@ -116,10 +116,12 @@ func (p *Pipeline) GenerateForUser(ctx context.Context, userID string) (*models.
systemPrompt = DefaultSystemPrompt
}
tz, _ := p.repo.GetSetting("timezone")
// Passe 2 : résumé complet
fmt.Printf("[pipeline] Passe 2 — résumé : génération sur %d articles…\n", len(articles))
t2 := time.Now()
prompt := buildPrompt(systemPrompt, symbols, articles)
prompt := buildPrompt(systemPrompt, symbols, articles, tz)
summary, err := provider.Summarize(ctx, prompt)
if err != nil {
return nil, fmt.Errorf("AI summarize: %w", err)
@ -266,7 +268,7 @@ func (p *Pipeline) callProviderForReport(ctx context.Context, excerpt, question
return provider.Summarize(ctx, prompt)
}
func buildPrompt(systemPrompt string, symbols []string, articles []models.Article) string {
func buildPrompt(systemPrompt string, symbols []string, articles []models.Article, tz string) string {
var sb strings.Builder
sb.WriteString(systemPrompt)
sb.WriteString("\n\n")
@ -275,7 +277,11 @@ func buildPrompt(systemPrompt string, symbols []string, articles []models.Articl
sb.WriteString(strings.Join(symbols, ", "))
sb.WriteString(".\n\n")
}
sb.WriteString(fmt.Sprintf("Date d'analyse : %s\n\n", time.Now().Format("02/01/2006 15:04")))
loc, err := time.LoadLocation(tz)
if err != nil || tz == "" {
loc = time.UTC
}
sb.WriteString(fmt.Sprintf("Date d'analyse : %s\n\n", time.Now().In(loc).Format("02/01/2006 15:04")))
sb.WriteString("/think\n\n")
sb.WriteString("## Actualités\n\n")

View File

@ -0,0 +1 @@
DELETE FROM settings WHERE key = 'timezone';

View File

@ -0,0 +1,2 @@
INSERT INTO settings (key, value) VALUES ('timezone', 'Europe/Paris')
ON CONFLICT (key) DO NOTHING;

View File

@ -57,9 +57,14 @@ func (s *Scheduler) loadSchedule() error {
return nil
}
tz, _ := s.repo.GetSetting("timezone")
if tz == "" {
tz = "UTC"
}
for _, slot := range slots {
// Format cron: "minute hour * * day_of_week"
spec := fmt.Sprintf("%d %d * * %d", slot.Minute, slot.Hour, slot.DayOfWeek)
// TZ= prefix permet à robfig/cron d'interpréter les heures dans le fuseau configuré
spec := fmt.Sprintf("TZ=%s %d %d * * %d", tz, slot.Minute, slot.Hour, slot.DayOfWeek)
id, err := s.cron.AddFunc(spec, s.run)
if err != nil {
fmt.Printf("scheduler: invalid cron spec %q: %v\n", spec, err)
@ -68,7 +73,7 @@ func (s *Scheduler) loadSchedule() error {
s.entryIDs = append(s.entryIDs, id)
}
fmt.Printf("scheduler: %d time slots loaded\n", len(s.entryIDs))
fmt.Printf("scheduler: %d time slots loaded (timezone: %s)\n", len(s.entryIDs), tz)
return nil
}