mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
db/events: ensure the latest author is used
This commit is contained in:
parent
e91fbf7b50
commit
4d655c904b
1 changed files with 9 additions and 3 deletions
|
|
@ -157,11 +157,17 @@ function getFilterQuery(filter: DittoFilter): EventQuery {
|
||||||
eb
|
eb
|
||||||
.selectFrom('events')
|
.selectFrom('events')
|
||||||
.selectAll()
|
.selectAll()
|
||||||
|
.select([
|
||||||
|
eb.fn.agg('row_number')
|
||||||
|
.over((ob) => ob.partitionBy('pubkey').orderBy('created_at', 'desc'))
|
||||||
|
.as('rn'),
|
||||||
|
])
|
||||||
.where('kind', '=', 0)
|
.where('kind', '=', 0)
|
||||||
.orderBy('created_at', 'desc')
|
|
||||||
.groupBy('pubkey')
|
|
||||||
.as('authors'),
|
.as('authors'),
|
||||||
(join) => join.onRef('authors.pubkey', '=', 'events.pubkey'),
|
(join) =>
|
||||||
|
join
|
||||||
|
.onRef('authors.pubkey', '=', 'events.pubkey')
|
||||||
|
.on('authors.rn', '=', 1),
|
||||||
)
|
)
|
||||||
.select([
|
.select([
|
||||||
'authors.id as author_id',
|
'authors.id as author_id',
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue