Skip to content
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

refactor: LivechatDepartmentAgents out of DB Watcher #32504

Merged
merged 14 commits into from
Jun 5, 2024

Conversation

ricardogarim
Copy link
Contributor

@ricardogarim ricardogarim commented May 27, 2024

As per the updates mentioned in PROJ-7, SCA-8 and ADR #74, this pull request focuses on relocating LivechatDepartmentAgents model out of DB Watcher service.

Context

This modification enhances RocketChat's app by allowing it to directly call listeners through the api.broadcast global function, bypassing the need for MongoDB Change Stream data propagation.

This change offers better control over user notifications via Web Sockets, enabling more precise management of use-cases. Instead of notifying every database change, we can now send an api.broadcast call only when necessary, reducing overall network messages. Additionally, this contributes to the future removal of the DB Watcher deployment, optimizing resource utilization.

Proposed changes

Key changes include:

  • Conditionally incorporating LivechatDepartmentAgents entity import within DB watchers on application startup based on the dbWatchersDisabled flag.
  • Enabling support for the following use cases to directly trigger watch.livechatDepartmentAgents listener event, subject to the dbWatchersDisabled flag.
Updated Use Cases
Use Case Route/Trigger Notes
Delete user POST Meteor method deleteUser
Delete user own account POST Meteor method deleteUserOwnAccount
App bridge delete user actions On app bridge deleteUser function
Remove agent On callback livechat.afterAgentRemoved triggered by
DELETE /api/v1/livechat/users/:type/:_id
POST Meteor method livechat:removeAgent
Archive/Unarchive department POST /api/v1/livechat/department/:_id/archive
POST /api/v1/livechat/department/:_id/unarchive
Remove department POST Meteor method livechat:removeDepartment
DELETE /api/v1/livechat/department/:_id

Steps to test or reproduce

  1. Start RocketChat's application with the DISABLE_DB_WATCHERS environment variable set to true.
  2. Perform HTTP requests or simulate use cases listed in the above table.

Further comments

To maintain consistency and avoid potential regressions, event names and signatures have been kept unchanged on both the client and app sides. This decision streamlines efforts and mitigates the risk of unintended consequences.

Additionally, some new model functions have been created to accommodate specific needs when dealing with database operations, such as LivechatDepartmentAgents.findAgentsByAgentsAndDepartmentId.

Copy link
Contributor

dionisio-bot bot commented May 27, 2024

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is targeting the wrong base branch. It should target 6.10.0, but it targets 6.9.0

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

Copy link

changeset-bot bot commented May 27, 2024

⚠️ No Changeset found

Latest commit: 9dd3ad1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

codecov bot commented May 27, 2024

Codecov Report

Attention: Patch coverage is 16.00000% with 21 lines in your changes missing coverage. Please review.

Project coverage is 56.36%. Comparing base (3da6e14) to head (9dd3ad1).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #32504      +/-   ##
===========================================
- Coverage    56.36%   56.36%   -0.01%     
===========================================
  Files         2435     2432       -3     
  Lines        53710    53704       -6     
  Branches     11062    11059       -3     
===========================================
- Hits         30273    30268       -5     
- Misses       20791    20796       +5     
+ Partials      2646     2640       -6     
Flag Coverage Δ
e2e 56.12% <ø> (+0.04%) ⬆️
unit 72.06% <0.00%> (-0.14%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

@ricardogarim ricardogarim marked this pull request as ready for review May 27, 2024 12:30
@ricardogarim ricardogarim requested review from a team as code owners May 27, 2024 12:30
@sampaiodiego sampaiodiego requested a review from a team as a code owner May 31, 2024 22:16
apps/meteor/app/livechat/server/lib/Departments.ts Outdated Show resolved Hide resolved
apps/meteor/app/livechat/server/lib/Helper.ts Outdated Show resolved Hide resolved
@sampaiodiego sampaiodiego marked this pull request as draft June 3, 2024 16:31
@sampaiodiego sampaiodiego force-pushed the refactor/livechat-dept-agent-out-of-db-watcher branch from 4a4664e to 8408c78 Compare June 4, 2024 21:24
@sampaiodiego sampaiodiego marked this pull request as ready for review June 5, 2024 19:08
sampaiodiego
sampaiodiego previously approved these changes Jun 5, 2024
@sampaiodiego sampaiodiego added this to the 6.10 milestone Jun 5, 2024
@sampaiodiego sampaiodiego added the stat: QA assured Means it has been tested and approved by a company insider label Jun 5, 2024
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Jun 5, 2024
@kodiakhq kodiakhq bot merged commit a3e4c06 into develop Jun 5, 2024
50 checks passed
@kodiakhq kodiakhq bot deleted the refactor/livechat-dept-agent-out-of-db-watcher branch June 5, 2024 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants