chore: add last twt on support
This commit is contained in:
3 files changed
+84
-36
No files matched your search
@@ -31,11 +31,11 @@ func httpServer(c *console, app *appState) error {
|
||||
_, span := otel.Span(r.Context())
|
||||
defer span.End()
|
||||
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
||||
w.Write([]byte("ok"))
|
||||
})
|
||||
|
||||
http.HandleFunc("/conv/{hash}", func(w http.ResponseWriter, r *http.Request) {
|
||||
http.HandleFunc("/api/plain/conv/{hash}", func(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, span := otel.Span(r.Context())
|
||||
defer span.End()
|
||||
|
||||
@@ -104,7 +104,7 @@ func httpServer(c *console, app *appState) error {
|
||||
reg.WriteTo(w)
|
||||
})
|
||||
|
||||
http.HandleFunc("/users", func(w http.ResponseWriter, r *http.Request) {
|
||||
http.HandleFunc("/api/plain/users", func(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, span := otel.Span(r.Context())
|
||||
defer span.End()
|
||||
|
||||
@@ -112,14 +112,20 @@ func httpServer(c *console, app *appState) error {
|
||||
|
||||
rows, err := db.QueryContext(
|
||||
ctx,
|
||||
`SELECT
|
||||
feed_id,
|
||||
uri,
|
||||
`SELECT
|
||||
feed_id,
|
||||
uri,
|
||||
nick,
|
||||
last_scan_on
|
||||
last_scan_on,
|
||||
last_twt_on
|
||||
FROM feeds
|
||||
where parent_id is null
|
||||
order by nick, uri`,
|
||||
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)
|
||||
where parent_id is null and state not in ('permanantly-dead', 'frozen') and last_twt_on is not null
|
||||
order by nick, uri
|
||||
`,
|
||||
)
|
||||
if err != nil {
|
||||
span.RecordError(err)
|
||||
@@ -134,15 +140,16 @@ func httpServer(c *console, app *appState) error {
|
||||
URI string
|
||||
Nick string
|
||||
Dt TwtTime
|
||||
LastTwtOn TwtTime
|
||||
}
|
||||
err = rows.Scan(&o.FeedID, &o.URI, &o.Nick, &o.Dt)
|
||||
err = rows.Scan(&o.FeedID, &o.URI, &o.Nick, &o.Dt, &o.LastTwtOn)
|
||||
if err != nil {
|
||||
span.RecordError(err)
|
||||
return
|
||||
}
|
||||
twts = append(twts, lextwt.NewTwt(
|
||||
types.NewTwter(o.Nick, o.URI),
|
||||
lextwt.NewDateTime(o.Dt.Time, o.Dt.Time.Format(time.RFC3339)),
|
||||
lextwt.NewDateTime(o.Dt.Time, o.LastTwtOn.Time.Format(time.RFC3339)),
|
||||
nil,
|
||||
))
|
||||
}
|
||||
@@ -150,7 +157,7 @@ func httpServer(c *console, app *appState) error {
|
||||
reg.WriteTo(w)
|
||||
})
|
||||
|
||||
http.HandleFunc("/queue", func(w http.ResponseWriter, r *http.Request) {
|
||||
http.HandleFunc("/api/plain/queue", func(w http.ResponseWriter, r *http.Request) {
|
||||
lis := slices.Collect(app.queue.Iter())
|
||||
sort.Slice(lis, func(i, j int) bool {
|
||||
return lis[i].NextScanOn.Time.Before(lis[j].LastScanOn.Time)
|
||||
|
||||
Reference in new issue
Block a user