summaryrefslogtreecommitdiff
path: root/internal/schedule
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-10-27 18:19:13 +0200
committerPaul Buetow <paul@buetow.org>2024-10-27 18:19:13 +0200
commit10eb852c01e84619340290d1cbaba0b116dd3267 (patch)
treea0e1d8fe74f55c3f5854a2bc03c6ba0c745d448a /internal/schedule
parent3d8935e6456bcfe462bd7735615e9009ef5ff7c6 (diff)
add now tag
Diffstat (limited to 'internal/schedule')
-rw-r--r--internal/schedule/schedule.go16
-rw-r--r--internal/schedule/stats.go6
2 files changed, 18 insertions, 4 deletions
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 {