chore: add last twt on support
This commit is contained in:
20
feed.go
20
feed.go
@@ -32,6 +32,7 @@ type Feed struct {
|
||||
LastScanOn TwtTime
|
||||
RefreshRate int
|
||||
NextScanOn TwtTime
|
||||
LastTwtOn TwtTime
|
||||
|
||||
LastModified TwtTime
|
||||
LastError sql.NullString
|
||||
@@ -102,20 +103,25 @@ var (
|
||||
select
|
||||
feed_id,
|
||||
parent_id,
|
||||
coalesce(hashing_uri, uri) hash_uri,
|
||||
coalesce(hashing_uri, uri) hash_uri,
|
||||
uri,
|
||||
nick,
|
||||
state,
|
||||
last_scan_on,
|
||||
strftime(
|
||||
'%Y-%m-%dT%H:%M:%fZ',
|
||||
'%Y-%m-%dT%H:%M:%fZ',
|
||||
coalesce(last_scan_on, '1901-01-01'),
|
||||
'+'||refresh_rate||' seconds'
|
||||
) next_scan_on,
|
||||
'+'||abs(refresh_rate + cast(random() % 30 as int))||' seconds'
|
||||
) next_scan_on,
|
||||
coalesce(last_twt_on, '1901-01-01T00:00:00Z') last_twt_on,
|
||||
refresh_rate,
|
||||
last_modified_on,
|
||||
last_etag
|
||||
from feeds
|
||||
left join (
|
||||
select feed_id, max(strftime('%Y-%m-%dT%H:%M:%fZ', (substring(text, 1, instr(text, ' ')-1)))) last_twt_on
|
||||
from twts group by feed_id
|
||||
) using (feed_id)
|
||||
left join (
|
||||
select
|
||||
feed_id parent_id,
|
||||
@@ -125,8 +131,8 @@ var (
|
||||
) using (parent_id)
|
||||
where datetime(
|
||||
coalesce(last_scan_on, '1901-01-01'),
|
||||
'+'||refresh_rate||' seconds'
|
||||
) < datetime(current_timestamp, '+2 minutes')
|
||||
'+'||abs(refresh_rate+cast(random()%30 as int))||' seconds'
|
||||
) < datetime(current_timestamp, '+3 minutes')
|
||||
`
|
||||
)
|
||||
|
||||
@@ -180,6 +186,7 @@ func (f *Feed) Scan(res interface{ Scan(...any) error }) error {
|
||||
&f.State,
|
||||
&f.LastScanOn,
|
||||
&f.NextScanOn,
|
||||
&f.LastTwtOn,
|
||||
&f.RefreshRate,
|
||||
&f.LastModified,
|
||||
&f.ETag,
|
||||
@@ -356,7 +363,6 @@ func storeFeed(ctx context.Context, db db, f types.TwtFile) error {
|
||||
}
|
||||
|
||||
func (feed *Feed) MakeHTTPRequest(ctx context.Context) (*http.Request, error) {
|
||||
feed.State = "fetch"
|
||||
if strings.Contains(feed.URI, "lublin.se") {
|
||||
return nil, fmt.Errorf("%w: permaban: %s", ErrPermanentlyDead, feed.URI)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user