-
Notifications
You must be signed in to change notification settings - Fork 11.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Apps-Engine method to read multiple messages from a room #32176
Conversation
Looks like this PR is ready to merge! 🎉 |
🦋 Changeset detectedLatest commit: 8a0e0fa The changes in this PR will be included in the next version bump. This PR includes changesets to release 32 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #32176 +/- ##
========================================
Coverage 55.57% 55.58%
========================================
Files 2634 2634
Lines 57273 57279 +6
Branches 11860 11860
========================================
+ Hits 31828 31837 +9
+ Misses 22759 22751 -8
- Partials 2686 2691 +5
Flags with carried forward coverage won't be shown. Click here to find out more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am also taking some questions back to the adr.
Depends on: RocketChat/Rocket.Chat.Apps-engine#770 |
Co-authored-by: Douglas Gubert <[email protected]>
Proposed changes (including videos or screenshots)
Added a new method,
getMessages
to fetch messages from a specific room. This method accepts aroomId
and anoptions
object as parameters. Theoptions
object can containlimit, skip, and sort
properties to control the query. The method uses theMessages.find
function to fetch the messages from the database and converts them using a message raw converter obtained from the orch object.Since a room can have a large number of messages, this method returns a maximum of 100 messages in a single call, to read more messages one can make another call passing the
skip
value. The default sort order is the descending order of timestamp (meaning the most recent messages will be returned), which can be overridden by passing thesort
parameter.Added a new converter
convertMessageRaw
it removes a few fields from the following (reason: comment ):Additionally, this new method removes the
delete
since the delete operator is generally slow and can cause performance issues. It modifies the underlying object, which can lead to deoptimization in JavaScript engines.Issue(s)
Steps to test or reproduce
To test as well as reproduce the issue and solution, try running the below in the App.
Output:
(Before this PR):
(After this PR):
You can pass your own query to filter the messages you want to retrieve. The available options are:
limit
: The number of messages to retrieve. (Default: 100 and Max: 100)skip
: The number of messages to skip.sort
: The sort order of the messages. e.g.{ ts: -1 }
will sort the messages by timestamp in descending order.Further comments
Execution Stats on a room with 3M messages