chore: fixes
This commit is contained in:
5 files changed
+35
-36
No files matched your search
@@ -25,21 +25,19 @@ const hostname = "https://watcher.sour.is"
|
||||
var PREAMBLE_DOCS = func() lextwt.Comments {
|
||||
c := add(nil, iAmTheWatcher)
|
||||
c = add(c, "")
|
||||
c = add(c,"Usage:")
|
||||
c = add(c," %s/api/plain/users View list of users and latest twt date.", hostname)
|
||||
c = add(c," %s/api/plain/twt View all twts in decending order.", hostname)
|
||||
c = add(c," %s/api/plain/mentions?uri=:uri View all mentions for uri in decending order.", hostname)
|
||||
c = add(c," %s/api/plain/conv/:hash View all twts for a conversation subject.", hostname)
|
||||
c = add(c,"")
|
||||
c = add(c,"Options:")
|
||||
c = add(c," uri Filter to show a specific users twts.")
|
||||
c = add(c," offset Start index for quey.")
|
||||
c = add(c," limit Count of items to return (going back in time).")
|
||||
return add(c,"")
|
||||
c = add(c, "Usage:")
|
||||
c = add(c, " %s/api/plain/users View list of users and latest twt date.", hostname)
|
||||
c = add(c, " %s/api/plain/twt View all twts in decending order.", hostname)
|
||||
c = add(c, " %s/api/plain/mentions?uri=:uri View all mentions for uri in decending order.", hostname)
|
||||
c = add(c, " %s/api/plain/conv/:hash View all twts for a conversation subject.", hostname)
|
||||
c = add(c, "")
|
||||
c = add(c, "Options:")
|
||||
c = add(c, " uri Filter to show a specific users twts.")
|
||||
c = add(c, " offset Start index for quey.")
|
||||
c = add(c, " limit Count of items to return (going back in time).")
|
||||
return add(c, "")
|
||||
}()
|
||||
|
||||
|
||||
|
||||
func httpServer(ctx context.Context, app *appState) error {
|
||||
ctx, span := otel.Span(ctx)
|
||||
defer span.End()
|
||||
@@ -139,10 +137,10 @@ func httpServer(ctx context.Context, app *appState) error {
|
||||
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
||||
|
||||
uri := r.URL.Query().Get("uri")
|
||||
if uri == ""{
|
||||
if uri == "" {
|
||||
reg := lextwt.NewTwtRegistry(PREAMBLE_DOCS, nil)
|
||||
reg.WriteTo(w)
|
||||
|
||||
|
||||
return
|
||||
}
|
||||
mention := urlNS.UUID5(uri)
|
||||
@@ -150,7 +148,6 @@ func httpServer(ctx context.Context, app *appState) error {
|
||||
args := make([]any, 0, 3)
|
||||
args = append(args, mention)
|
||||
|
||||
|
||||
limit := 100
|
||||
if v, ok := strconv.Atoi(r.URL.Query().Get("limit")); ok == nil {
|
||||
limit = v
|
||||
@@ -200,7 +197,6 @@ func httpServer(ctx context.Context, app *appState) error {
|
||||
`
|
||||
fmt.Println(qry, args)
|
||||
|
||||
|
||||
rows, err := db.QueryContext(
|
||||
ctx, qry, args...,
|
||||
)
|
||||
@@ -249,7 +245,6 @@ func httpServer(ctx context.Context, app *appState) error {
|
||||
reg.WriteTo(w)
|
||||
})
|
||||
|
||||
|
||||
http.HandleFunc("/api/plain/twt", func(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, span := otel.Span(r.Context())
|
||||
defer span.End()
|
||||
@@ -266,7 +261,7 @@ func httpServer(ctx context.Context, app *appState) error {
|
||||
offset = v
|
||||
}
|
||||
|
||||
twts, end, err := func(uri string, limit int, offset int64, ) ([]types.Twt, int64, error) {
|
||||
twts, end, err := func(uri string, limit int, offset int64) ([]types.Twt, int64, error) {
|
||||
args := make([]any, 0, 3)
|
||||
where := `where feed_id in (select feed_id from feeds where state != 'permanantly-dead')`
|
||||
|
||||
@@ -311,7 +306,7 @@ func httpServer(ctx context.Context, app *appState) error {
|
||||
) using (feed_id)
|
||||
where rowid in (
|
||||
select rowid from twts
|
||||
` + where +`
|
||||
` + where + `
|
||||
order by ulid asc
|
||||
limit ?
|
||||
offset ?
|
||||
@@ -351,7 +346,7 @@ func httpServer(ctx context.Context, app *appState) error {
|
||||
}
|
||||
|
||||
return twts, end, err
|
||||
} (uri, limit, offset)
|
||||
}(uri, limit, offset)
|
||||
span.RecordError(err)
|
||||
|
||||
preamble := add(PREAMBLE_DOCS, "twt range = 1 %d", end)
|
||||
|
||||
Reference in new issue
Block a user