From 10eb852c01e84619340290d1cbaba0b116dd3267 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 27 Oct 2024 18:19:13 +0200 Subject: add now tag --- internal/schedule/schedule.go | 16 +++++++++++++--- internal/schedule/stats.go | 6 +++++- 2 files changed, 18 insertions(+), 4 deletions(-) (limited to 'internal/schedule') diff --git a/internal/schedule/schedule.go b/internal/schedule/schedule.go index b6be6be..5ac2732 100644 --- a/internal/schedule/schedule.go +++ b/internal/schedule/schedule.go @@ -27,13 +27,23 @@ func Run(args config.Args, platform string) (entry.Entry, error) { } log.Println("For", platform, "stats:", stats) + // Schedule random queued entry with "now" tag, ignoring the target hit stats. + // TODO: Document .now. tag + ent, err := selectRandomEntry(dir, "now") + if err != nil && !errors.Is(err, oi.ErrNotFound) { + // Unknown error + return ent, nil + } + if err == nil { + return ent, nil + } + if stats.targetHit(args.PauseDays) { return entry.Zero, ErrNothingToSchedule } - // Schedule random qeued entry for platform. First, try to find one with - // a priority tag. - ent, err := selectRandomEntry(dir, "prio") + // Schedule random qeued entry for platform. Find one with prio tag. + ent, err = selectRandomEntry(dir, "prio") if errors.Is(err, oi.ErrNotFound) { // No entry with priority tag found, select another one. ent, err = selectRandomEntry(dir, "") diff --git a/internal/schedule/stats.go b/internal/schedule/stats.go index bf5a12c..77271fe 100644 --- a/internal/schedule/stats.go +++ b/internal/schedule/stats.go @@ -5,6 +5,7 @@ import ( "log" "os" "path/filepath" + "strings" "time" "codeberg.org/snonux/gos/internal/entry" @@ -76,7 +77,10 @@ func (s *stats) gatherPostedStats(dir string, lookbackTime time.Time) error { if ent.Time.After(newest) { newest = ent.Time } - s.posted++ + // Ignore .now. + if !strings.Contains(file.Name(), ".now.") { + s.posted++ + } return nil }) if err != nil { -- cgit v1.2.3