diff --git a/feed.go b/feed.go index 17d980b..a907498 100644 --- a/feed.go +++ b/feed.go @@ -71,7 +71,7 @@ var ( state, last_scan_on, refresh_rate - ) + ) values (?, ?, ?, ?, ?, ?, ?)` + repeat + ` ON CONFLICT (feed_id) DO NOTHING`, r * 7 } @@ -92,26 +92,26 @@ var ( repeat = strings.Repeat(", (?, ?, ?, ?, ?, ?, ?)", r-1) } return ` - insert into twts - (feed_id, ulid, text, hash, conv, mentions, tags) + insert into twts + (feed_id, ulid, text, hash, conv, mentions, tags) values (?, ?, ?, ?, ?, ?, ?)` + repeat + ` ON CONFLICT (feed_id, ulid) DO NOTHING`, r * 7 } fetchFeeds = ` - select + select feed_id, - parent_id, - coalesce(hashing_uri, uri) hash_uri, + parent_id, + coalesce(hashing_uri, uri) hash_uri, uri, nick, - state, + state, last_scan_on, strftime( '%Y-%m-%dT%H:%M:%fZ', - coalesce(last_scan_on, '1901-01-01'), + coalesce(last_scan_on, '1901-01-01'), '+'||refresh_rate||' seconds' - ) next_scan_on, + ) next_scan_on, refresh_rate, last_modified_on, last_etag @@ -124,9 +124,9 @@ var ( where parent_id is null ) using (parent_id) where datetime( - coalesce(last_scan_on, '1901-01-01'), + coalesce(last_scan_on, '1901-01-01'), '+'||refresh_rate||' seconds' - ) < datetime(current_timestamp, '+10 minutes') + ) < datetime(current_timestamp, '+2 minutes') ` ) @@ -310,7 +310,7 @@ func storeFeed(ctx context.Context, db db, f types.TwtFile) error { TwtTime{Time: loadTS, Valid: true}, // last_scan_on refreshRate, // refresh_rate ) - + if prev, ok := f.Info().GetN("prev", 0); ok { _, part, ok := strings.Cut(prev.Value(), " ") if ok { @@ -319,7 +319,7 @@ func storeFeed(ctx context.Context, db db, f types.TwtFile) error { childID := urlNS.UUID5(part) args = append(args, - childID, // feed_id + childID, // feed_id feedID, // parent_id f.Twter().DomainNick(), // nick part, // uri @@ -463,5 +463,3 @@ func chunk(args []any, qry func(int) (string, int), maxArgs int) iter.Seq2[strin } } } - - diff --git a/refresh-loop.go b/refresh-loop.go index 3ecef61..c0789f6 100644 --- a/refresh-loop.go +++ b/refresh-loop.go @@ -65,7 +65,7 @@ func feedRefreshProcessor(c *console, app *appState) error { f := queue.ExtractMin() if f == nil { - sleeping_time.Add(ctx, int64(TenMinutes)) + sleeping_time.Add(ctx, int64(TwoMinutes)) span.AddEvent("sleeping for ", trace.WithAttributes(attribute.Int("seconds", int(TenMinutes)))) select { case <-time.After(TenMinutes * time.Second):