Arsnael commented on PR #2792:
URL: https://github.com/apache/james-project/pull/2792#issuecomment-3584290891
> For PG we likely could try DINSTINT ON
I tried to play around with it a bit. For listMailboxContentSortedBySentAt:
```
public Flux<MessageId> listMailboxContentSortedBySentAt(PostgresMailboxId
mailboxId, Limit limit, boolean collapseThreads) {
Preconditions.checkArgument(!limit.isUnlimited(), "Limit should be
defined");
if (collapseThreads) {
return postgresExecutor.executeRows(dslContext ->
Flux.from(dslContext.select(THREAD_ID, MESSAGE_ID)
.distinctOn(THREAD_ID)
.from(TABLE_NAME)
.where(MAILBOX_ID.eq(mailboxId.asUuid()))
.orderBy(THREAD_ID.asc(), SENT_AT.desc())
.limit(limit.getLimit().get())))
.map(record ->
PostgresMessageId.Factory.of(record.get(MESSAGE_ID)));
}
return postgresExecutor.executeRows(dslContext ->
Flux.from(dslContext.select(MESSAGE_ID)
.from(TABLE_NAME)
.where(MAILBOX_ID.eq(mailboxId.asUuid()))
.orderBy(SENT_AT.desc())
.limit(limit.getLimit().get())))
.map(record ->
PostgresMessageId.Factory.of(record.get(MESSAGE_ID)));
}
```
Unfortunately the test
`listMailboxContentSortedBySentAtShouldApplyLimitWithCollapseThreads` is
failing. I have message id 4 first in the list returned which is good, but then
I get message id 1... while I should get message id 3. I could not manage to
pass it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]