chore: add twt_mentions table
This commit is contained in:
parent
fc762f3bf3
commit
aedc9245e5
17
feed.go
17
feed.go
@ -605,14 +605,25 @@ func chunk(args []any, qry func(int) (string, int), maxArgs int) iter.Seq2[strin
|
||||
}
|
||||
|
||||
func refreshLastTwt(ctx context.Context, db db) error {
|
||||
_, err := db.ExecContext(ctx, `
|
||||
qry := `
|
||||
delete from last_twt_on;
|
||||
insert into last_twt_on
|
||||
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
|
||||
on conflict do update set last_twt_on = excluded.last_twt_on;
|
||||
`)
|
||||
on conflict(feed_id) do update set last_twt_on = excluded.last_twt_on;
|
||||
delete from twt_mentions;
|
||||
insert into twt_mentions select ulid, unhex(replace(trim(value,'{}'),'-','')) feed_id from twts, json_each(mentions);
|
||||
`
|
||||
var err error
|
||||
for _, stmt := range strings.Split(qry, ";") {
|
||||
_, err = db.ExecContext(ctx, stmt)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user