chore: show last scan for child feeds
This commit is contained in:
parent
d85dd56ac9
commit
84c3099be6
84
http.go
84
http.go
@ -134,7 +134,7 @@ func httpServer(ctx context.Context, app *appState) error {
|
|||||||
|
|
||||||
var end int64
|
var end int64
|
||||||
err = db.QueryRowContext(ctx, `
|
err = db.QueryRowContext(ctx, `
|
||||||
select count(*) n from twts
|
select count(*) n from twts
|
||||||
JOIN (
|
JOIN (
|
||||||
SELECT
|
SELECT
|
||||||
feed_id,
|
feed_id,
|
||||||
@ -159,29 +159,31 @@ func httpServer(ctx context.Context, app *appState) error {
|
|||||||
attribute.Int64("offset-start", offset-int64(limit)),
|
attribute.Int64("offset-start", offset-int64(limit)),
|
||||||
attribute.Int64("max", end),
|
attribute.Int64("max", end),
|
||||||
))
|
))
|
||||||
|
qry := `
|
||||||
|
SELECT
|
||||||
|
feed_id,
|
||||||
|
hash,
|
||||||
|
conv,
|
||||||
|
nick,
|
||||||
|
uri,
|
||||||
|
text
|
||||||
|
FROM twts
|
||||||
|
JOIN (
|
||||||
|
SELECT
|
||||||
|
feed_id,
|
||||||
|
nick,
|
||||||
|
uri
|
||||||
|
FROM feeds
|
||||||
|
where ` + uriarg + `
|
||||||
|
) using (feed_id)
|
||||||
|
order by ulid asc
|
||||||
|
limit ?
|
||||||
|
offset ?
|
||||||
|
`
|
||||||
|
fmt.Println(qry, args)
|
||||||
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
||||||
rows, err := db.QueryContext(
|
rows, err := db.QueryContext(
|
||||||
ctx,
|
ctx, qry, args...,
|
||||||
`SELECT
|
|
||||||
feed_id,
|
|
||||||
hash,
|
|
||||||
conv,
|
|
||||||
nick,
|
|
||||||
uri,
|
|
||||||
text
|
|
||||||
FROM twts
|
|
||||||
JOIN (
|
|
||||||
SELECT
|
|
||||||
feed_id,
|
|
||||||
nick,
|
|
||||||
uri
|
|
||||||
FROM feeds
|
|
||||||
where `+uriarg+`
|
|
||||||
) using (feed_id)
|
|
||||||
order by ulid asc
|
|
||||||
limit ?
|
|
||||||
offset ?
|
|
||||||
`, args...,
|
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
span.RecordError(err)
|
span.RecordError(err)
|
||||||
@ -239,25 +241,27 @@ func httpServer(ctx context.Context, app *appState) error {
|
|||||||
args = append(args, feed_id, feed_id)
|
args = append(args, feed_id, feed_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
rows, err := db.QueryContext(
|
qry := `
|
||||||
ctx,
|
SELECT
|
||||||
`SELECT
|
feed_id,
|
||||||
|
uri,
|
||||||
|
nick,
|
||||||
|
last_scan_on,
|
||||||
|
coalesce(last_twt_on, last_scan_on) last_twt_on
|
||||||
|
FROM feeds
|
||||||
|
left join (
|
||||||
|
select
|
||||||
feed_id,
|
feed_id,
|
||||||
uri,
|
max(strftime('%Y-%m-%dT%H:%M:%fZ', (substring(text, 1, instr(text, ' ')-1)))) last_twt_on
|
||||||
nick,
|
from twts
|
||||||
last_scan_on,
|
group by feed_id
|
||||||
last_twt_on
|
) using (feed_id)
|
||||||
FROM feeds
|
` + where + `
|
||||||
left join (
|
order by nick, uri
|
||||||
select
|
`
|
||||||
feed_id,
|
fmt.Println(qry, args)
|
||||||
max(strftime('%Y-%m-%dT%H:%M:%fZ', (substring(text, 1, instr(text, ' ')-1)))) last_twt_on
|
|
||||||
from twts group by feed_id
|
rows, err := db.QueryContext(ctx, qry, args...)
|
||||||
) using (feed_id)
|
|
||||||
`+where+`
|
|
||||||
order by nick, uri
|
|
||||||
`, args...,
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
span.RecordError(err)
|
span.RecordError(err)
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user