chore: go fmt

This commit is contained in:
xuu 2025-03-26 15:38:25 -06:00
parent b34c9bc99f
commit fe28b7c2ad
Signed by: xuu
GPG Key ID: 8B3B0604F164E04F
5 changed files with 40 additions and 37 deletions

19
feed.go
View File

@ -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 {

View File

@ -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)

View File

@ -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"

View File

@ -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"

View File

@ -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
}
return "[" + strings.Join(arr, ",") + "]", nil
}