From fe28b7c2ad4686982b2b16cb7a393e6fa6d29849 Mon Sep 17 00:00:00 2001 From: xuu Date: Wed, 26 Mar 2025 15:38:25 -0600 Subject: [PATCH] chore: go fmt --- feed.go | 19 +++++++++-------- http.go | 2 +- internal/otel/otel.go | 2 +- refresh-loop.go | 48 +++++++++++++++++++++---------------------- uuid.go | 6 +++--- 5 files changed, 40 insertions(+), 37 deletions(-) diff --git a/feed.go b/feed.go index 0510a7d..120475e 100644 --- a/feed.go +++ b/feed.go @@ -32,7 +32,7 @@ type Feed struct { LastScanOn TwtTime RefreshRate int NextScanOn TwtTime - LastTwtOn TwtTime + LastTwtOn TwtTime LastModified TwtTime LastError sql.NullString @@ -321,7 +321,7 @@ func storeFeed(ctx context.Context, db db, f types.TwtFile) error { if prev, ok := f.Info().GetN("prev", 0); ok { _, part, ok := strings.Cut(prev.Value(), " ") if ok { - uri:= f.Twter().URI + uri := f.Twter().URI if u, ok := f.Info().GetN("url", 0); ok { uri = u.Value() } @@ -333,13 +333,13 @@ func storeFeed(ctx context.Context, db db, f types.TwtFile) error { childID := urlNS.UUID5(part) fmt.Println("found prev", uri, part) args = append(args, - childID, // feed_id - feedID, // parent_id + childID, // feed_id + feedID, // parent_id f.Twter().DomainNick(), // nick - part, // uri - "once", // state - nil, // last_scan_on - 0, // refresh_rate + part, // uri + "once", // state + nil, // last_scan_on + 0, // refresh_rate ) } } @@ -373,6 +373,9 @@ func (feed *Feed) MakeHTTPRequest(ctx context.Context) (*http.Request, error) { if strings.Contains(feed.URI, "lublin.se") { return nil, fmt.Errorf("%w: permaban: %s", ErrPermanentlyDead, feed.URI) } + if strings.Contains(feed.URI, "enotty.dk") { + return nil, fmt.Errorf("%w: permaban: %s", ErrPermanentlyDead, feed.URI) + } req, err := http.NewRequestWithContext(ctx, "GET", feed.URI, nil) if err != nil { diff --git a/http.go b/http.go index 9b49b5a..47d443d 100644 --- a/http.go +++ b/http.go @@ -106,7 +106,7 @@ func httpServer(c *console, app *appState) error { }) http.HandleFunc("/api/plain/twt", func(w http.ResponseWriter, r *http.Request) { - ctx, span := otel.Span(r.Context()) + ctx, span := otel.Span(r.Context()) defer span.End() args := make([]any, 0, 3) diff --git a/internal/otel/otel.go b/internal/otel/otel.go index 6162517..95bcca0 100644 --- a/internal/otel/otel.go +++ b/internal/otel/otel.go @@ -20,7 +20,7 @@ import ( otelprom "go.opentelemetry.io/otel/exporters/prometheus" "go.opentelemetry.io/otel/exporters/stdout/stdoutlog" "go.opentelemetry.io/otel/exporters/stdout/stdouttrace" - "go.opentelemetry.io/otel/log/global" + "go.opentelemetry.io/otel/log/global" "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/propagation" "go.opentelemetry.io/otel/sdk/log" diff --git a/refresh-loop.go b/refresh-loop.go index 0edf3ab..186e643 100644 --- a/refresh-loop.go +++ b/refresh-loop.go @@ -140,7 +140,7 @@ func processorLoop(ctx context.Context, db db, fetch *pool[*Feed, *Response]) { err := res.err if res.err != nil { if errors.Is(err, ErrPermanentlyDead) { - f.State = "permanantly-dead" + f.State = "permanantly-dead" f.RefreshRate = TenYear } if errors.Is(err, ErrTemporarilyDead) { @@ -220,39 +220,39 @@ func processorLoop(ctx context.Context, db db, fetch *pool[*Feed, *Response]) { func checkTemp(twts types.Twts) (int, State) { if len(twts) < 5 { - return 7*OneDay, "cold" + return 7 * OneDay, "cold" } sort.Sort(twts) since_first := -time.Until(twts[0].Created()) since_fifth := -time.Until(twts[4].Created()) - if since_first < 2 * time.Hour || since_fifth < 8 * time.Hour { + if since_first < 2*time.Hour || since_fifth < 8*time.Hour { return TwoMinutes, "hot" } - if since_first < 4 * time.Hour || since_fifth < 16 * time.Hour{ + if since_first < 4*time.Hour || since_fifth < 16*time.Hour { return TenMinutes, "hot" } - if since_first < 8 * time.Hour || since_fifth < 32 * time.Hour{ - return 2*TenMinutes, "warm" + if since_first < 8*time.Hour || since_fifth < 32*time.Hour { + return 2 * TenMinutes, "warm" } - if since_first < 16 * time.Hour || since_fifth < 64 * time.Hour{ - return 4*TenMinutes, "warm" + if since_first < 16*time.Hour || since_fifth < 64*time.Hour { + return 4 * TenMinutes, "warm" } - if since_first < 24 * time.Hour || since_fifth < 128 * time.Hour{ + if since_first < 24*time.Hour || since_fifth < 128*time.Hour { return OneDay, "cold" } - if since_first < 48 * time.Hour || since_fifth < 256 * time.Hour{ - return 2*OneDay, "cold" + if since_first < 48*time.Hour || since_fifth < 256*time.Hour { + return 2 * OneDay, "cold" } - if since_first < 96 * time.Hour || since_fifth < 512 * time.Hour{ - return 7*OneDay, "frozen" + if since_first < 96*time.Hour || since_fifth < 512*time.Hour { + return 7 * OneDay, "frozen" } return OneMonth, "frozen" @@ -261,32 +261,32 @@ func checkTemp(twts types.Twts) (int, State) { func tsTemp(ts time.Time) (int, State) { since_first := -time.Until(ts) - if since_first < 2 * time.Hour { + if since_first < 2*time.Hour { return TwoMinutes, "hot" } - if since_first < 4 * time.Hour { + if since_first < 4*time.Hour { return TenMinutes, "hot" } - if since_first < 8 * time.Hour { - return 2*TenMinutes, "warm" + if since_first < 8*time.Hour { + return 2 * TenMinutes, "warm" } - if since_first < 16 * time.Hour { - return 4*TenMinutes, "warm" + if since_first < 16*time.Hour { + return 4 * TenMinutes, "warm" } - if since_first < 24 * time.Hour { + if since_first < 24*time.Hour { return OneDay, "cold" } - if since_first < 48 * time.Hour { - return 2*OneDay, "cold" + if since_first < 48*time.Hour { + return 2 * OneDay, "cold" } - if since_first < 96 * time.Hour { - return 7*OneDay, "frozen" + if since_first < 96*time.Hour { + return 7 * OneDay, "frozen" } return OneMonth, "frozen" diff --git a/uuid.go b/uuid.go index bd3dc87..fd0b181 100644 --- a/uuid.go +++ b/uuid.go @@ -70,8 +70,8 @@ func (l *strList) Scan(value any) error { func (l strList) Value() (driver.Value, error) { arr := make([]string, len(l)) for i, v := range l { - arr[i] = "\""+v+"\"" + arr[i] = "\"" + v + "\"" } - return "["+strings.Join(arr, ",") +"]", nil -} \ No newline at end of file + return "[" + strings.Join(arr, ",") + "]", nil +}