[Fixes #170] allow users of mdk to choose whether to sort by createdAt or processedAt first#171
Conversation
❌ Coverage: 90.99% → 90.5% (-0.49%) |
|
@coderabbitai no reviews? |
|
✅ Actions performedReview triggered.
|
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughAdds configurable message sort order (CreatedAtFirst, ProcessedAtFirst), threads sort_order through Pagination, implements sort-aware messages() and new last_message() across storage layers, adds a DB index for ProcessedAtFirst, and exposes sort-order-aware APIs in core and UniFFI; tests updated for sorting and pagination. Changes
Sequence Diagram(s)sequenceDiagram
participant Client as UniFFI Client
participant Core as MDK Core
participant Storage as GroupStorage impl
participant DB as Database
Client->>Core: get_last_message(group_id, sort_order)
Core->>Storage: last_message(group_id, sort_order)
Storage->>DB: query (ORDER BY based on sort_order LIMIT 1)
DB-->>Storage: row / none
Storage-->>Core: Message | None
Core-->>Client: Message | None
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
❌ Coverage: 90.95% → 90.46% (-0.49%) |
I don't know if this is the right approach honestly, or if this is even a good idea in the first place
This PR adds configurable message sort order across the mdk stack and a matching "last message" retrieval that respects the chosen ordering, so clients can choose to order messages by created_at (default) or by processed_at (local reception time) and get a consistent last-message value. The change propagates a new MessageSortOrder enum and a sort_order field on Pagination through storage traits, storage implementations, core APIs, and UniFFI bindings, with tests and a SQLite index to support processed-at-first queries.
What changed:
Security impact:
Protocol changes:
API surface:
Testing: