chore: fixes
This commit is contained in:
parent
aedc9245e5
commit
69755e14d2
12
feed.go
12
feed.go
@ -563,7 +563,7 @@ func (n TwtTime) Value() (driver.Value, error) {
|
||||
}
|
||||
|
||||
func makeULID(twt types.Twt) ulid.ULID {
|
||||
text := fmt.Appendf(nil, "%s\t%+l", cmp.Or(twt.Twter().HashingURI, twt.Twter().URI), twt)
|
||||
text := fmt.Appendf(nil, "%s\t%+l", twt.Twter().URI, twt)
|
||||
u := ulid.ULID{}
|
||||
u.SetTime(ulid.Timestamp(twt.Created()))
|
||||
u.SetEntropy(sha3.SumSHAKE128(text, 10))
|
||||
@ -608,14 +608,18 @@ func refreshLastTwt(ctx context.Context, db db) error {
|
||||
qry := `
|
||||
delete from last_twt_on;
|
||||
insert into last_twt_on
|
||||
select
|
||||
select distinct
|
||||
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
|
||||
on conflict(feed_id) do update set last_twt_on = excluded.last_twt_on;
|
||||
on conflict(feed_id);
|
||||
delete from twt_mentions;
|
||||
insert into twt_mentions select ulid, unhex(replace(trim(value,'{}'),'-','')) feed_id from twts, json_each(mentions);
|
||||
insert into twt_mentions
|
||||
select distinct
|
||||
ulid,
|
||||
unhex(replace(trim(value,'{}'),'-','')) feed_id
|
||||
from twts, json_each(mentions);
|
||||
`
|
||||
var err error
|
||||
for _, stmt := range strings.Split(qry, ";") {
|
||||
|
7
http.go
7
http.go
@ -38,8 +38,6 @@ var PREAMBLE_DOCS = func() lextwt.Comments {
|
||||
return add(c, "")
|
||||
}()
|
||||
|
||||
|
||||
|
||||
func httpServer(ctx context.Context, app *appState) error {
|
||||
ctx, span := otel.Span(ctx)
|
||||
defer span.End()
|
||||
@ -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')`
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user