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

Development: Avoid unnecessary fetching of messages and posts #7357

Merged
merged 12 commits into from
Oct 13, 2023

Conversation

lennart-keller
Copy link
Contributor

@lennart-keller lennart-keller commented Oct 11, 2023

Checklist

General

Client

  • Important: I implemented the changes with a very good performance, prevented too many (unnecessary) REST calls and made sure the UI is responsive, even with large data.
  • I followed the coding and design guidelines.
  • Following the theming guidelines, I specified colors only in the theming variable files and checked that the changes look consistent in both the light and the dark theme.
  • I added multiple integration tests (Jest) related to the features (with a high test coverage), while following the test guidelines.
  • I documented the TypeScript code using JSDoc style.

Motivation and Context

When a client receives a new or updated Q&A post or conversation message via WebSocket, it currently fetches the last 50 messages, despite the WebSocket message providing all necessary information for appropriate client updates. Particularly when numerous users are online simultaneously, this approach generates a substantial number of unnecessary GET requests that the servers must process.

Description

Upon receiving a WebSocket message for an updated or created post/message, the client now updates the list of stored posts/messages accordingly without triggering an unnecessary REST request. The only exception is, when new Q&A posts are received. Adapting this use case would require to implement the server-side filtering in the client-side. However, since this use case is deprecated, it will not be changed in this PR.

Steps for Testing

Prerequisites:

  • 2 Students
  • 1 Course with messaging and communication
  1. Write messages/posts. Also react, edit, reply, and resolve messages/posts
  2. Confirm (with the help of the Chrome developer tools) that GET /posts or GET /messages requests are only made (besides loading a page initially) if:
    1. another conversation is opened on the messages tab
    2. a new Q&A post is created (communication tab)
    3. you search for messages/posts or change other filtering settings

In all other cases, neither the author nor another involved course member (2nd student) makes GET requests

Review Progress

Performance Review

  • I (as a reviewer) confirm that the client changes (in particular related to REST calls and UI responsiveness) are implemented with a very good performance
  • I (as a reviewer) confirm that the server changes (in particular related to database calls) are implemented with a very good performance

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Test Coverage

Client

Class/File Line Coverage Confirmation (assert/expect)
course-discussion.component.ts 95.28%
metis.service.ts 95.58%

Screenshots

No major UI changes (just a bugfix, because the post context filter was transparent):
before:
before

after:
after

@lennart-keller lennart-keller self-assigned this Oct 11, 2023
@lennart-keller lennart-keller requested a review from a team as a code owner October 11, 2023 15:14
@github-actions github-actions bot added tests client Pull requests that update TypeScript code. (Added Automatically!) labels Oct 11, 2023
@github-actions
Copy link

❌ Unable to deploy to test servers ❌

Testserver "artemis-test5.artemis.cit.tum.de" is already in use by PR #7358.

@github-actions github-actions bot added the deployment-error Added by deployment workflows if an error occured label Oct 11, 2023
@basak-akan basak-akan removed the deployment-error Added by deployment workflows if an error occured label Oct 11, 2023
Copy link
Contributor

@basak-akan basak-akan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on TS2.

  • Writing messages/posts, reacting, editing, replying, and resolving messages worked as expected.
  • GET /posts or GET /messages requests are only made for given situations

@lennart-keller lennart-keller changed the title Development: Eliminate unnecessary message retrieval Development: Avoid unnecessary fetching of messages and posts Oct 11, 2023
Copy link
Collaborator

@MaximilianAnzinger MaximilianAnzinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code lgtm

Copy link
Contributor

@terlan98 terlan98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on TS2. Works as expected 👍

Copy link
Contributor

@valentin-boehm valentin-boehm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@krusche krusche added this to the 6.6.0 milestone Oct 13, 2023
@krusche krusche merged commit 443f4c7 into develop Oct 13, 2023
@krusche krusche deleted the bugfix/communication/unnecessary-getposts-call branch October 13, 2023 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Pull requests that update TypeScript code. (Added Automatically!) ready to merge tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants