chore: adjust timing

This commit is contained in:
xuu 2025-03-24 22:29:18 -06:00
parent dae57540e3
commit 2de06ec4d9
Signed by: xuu
GPG Key ID: 8B3B0604F164E04F
2 changed files with 14 additions and 16 deletions

28
feed.go
View File

@ -71,7 +71,7 @@ var (
state, state,
last_scan_on, last_scan_on,
refresh_rate refresh_rate
) )
values (?, ?, ?, ?, ?, ?, ?)` + repeat + ` values (?, ?, ?, ?, ?, ?, ?)` + repeat + `
ON CONFLICT (feed_id) DO NOTHING`, r * 7 ON CONFLICT (feed_id) DO NOTHING`, r * 7
} }
@ -92,26 +92,26 @@ var (
repeat = strings.Repeat(", (?, ?, ?, ?, ?, ?, ?)", r-1) repeat = strings.Repeat(", (?, ?, ?, ?, ?, ?, ?)", r-1)
} }
return ` return `
insert into twts insert into twts
(feed_id, ulid, text, hash, conv, mentions, tags) (feed_id, ulid, text, hash, conv, mentions, tags)
values (?, ?, ?, ?, ?, ?, ?)` + repeat + ` values (?, ?, ?, ?, ?, ?, ?)` + repeat + `
ON CONFLICT (feed_id, ulid) DO NOTHING`, r * 7 ON CONFLICT (feed_id, ulid) DO NOTHING`, r * 7
} }
fetchFeeds = ` fetchFeeds = `
select select
feed_id, feed_id,
parent_id, parent_id,
coalesce(hashing_uri, uri) hash_uri, coalesce(hashing_uri, uri) hash_uri,
uri, uri,
nick, nick,
state, state,
last_scan_on, last_scan_on,
strftime( strftime(
'%Y-%m-%dT%H:%M:%fZ', '%Y-%m-%dT%H:%M:%fZ',
coalesce(last_scan_on, '1901-01-01'), coalesce(last_scan_on, '1901-01-01'),
'+'||refresh_rate||' seconds' '+'||refresh_rate||' seconds'
) next_scan_on, ) next_scan_on,
refresh_rate, refresh_rate,
last_modified_on, last_modified_on,
last_etag last_etag
@ -124,9 +124,9 @@ var (
where parent_id is null where parent_id is null
) using (parent_id) ) using (parent_id)
where datetime( where datetime(
coalesce(last_scan_on, '1901-01-01'), coalesce(last_scan_on, '1901-01-01'),
'+'||refresh_rate||' seconds' '+'||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 TwtTime{Time: loadTS, Valid: true}, // last_scan_on
refreshRate, // refresh_rate refreshRate, // refresh_rate
) )
if prev, ok := f.Info().GetN("prev", 0); ok { if prev, ok := f.Info().GetN("prev", 0); ok {
_, part, ok := strings.Cut(prev.Value(), " ") _, part, ok := strings.Cut(prev.Value(), " ")
if ok { if ok {
@ -319,7 +319,7 @@ func storeFeed(ctx context.Context, db db, f types.TwtFile) error {
childID := urlNS.UUID5(part) childID := urlNS.UUID5(part)
args = append(args, args = append(args,
childID, // feed_id childID, // feed_id
feedID, // parent_id feedID, // parent_id
f.Twter().DomainNick(), // nick f.Twter().DomainNick(), // nick
part, // uri part, // uri
@ -463,5 +463,3 @@ func chunk(args []any, qry func(int) (string, int), maxArgs int) iter.Seq2[strin
} }
} }
} }

View File

@ -65,7 +65,7 @@ func feedRefreshProcessor(c *console, app *appState) error {
f := queue.ExtractMin() f := queue.ExtractMin()
if f == nil { 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)))) span.AddEvent("sleeping for ", trace.WithAttributes(attribute.Int("seconds", int(TenMinutes))))
select { select {
case <-time.After(TenMinutes * time.Second): case <-time.After(TenMinutes * time.Second):