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

Limit the number of notifications requests #4373

Merged
merged 13 commits into from
Jan 31, 2023
Merged

Conversation

jorg-vr
Copy link
Contributor

@jorg-vr jorg-vr commented Jan 30, 2023

This pull request limits the numbers of notifications requests in two ways;

  1. Notifications are only updated automatically if a user has open questions
  2. Notifications get updated less often if a tab is inactive

A new gem counter_culture was added that introduces conditional counter cache. This is used to cache the number of open questions for a user.

This should be run manually in the console, to initialize counter cache:

User.find_each do |u|
   u.update(open_questions_count: u.questions.where.not(question_state: :answered).count)
 end
  • Tests were added

Closes #3576

@jorg-vr jorg-vr added the chore Repository/build/dependency maintenance label Jan 30, 2023
@jorg-vr jorg-vr self-assigned this Jan 30, 2023
@jorg-vr jorg-vr marked this pull request as ready for review January 30, 2023 15:05
@jorg-vr jorg-vr requested a review from a team as a code owner January 30, 2023 15:05
@jorg-vr jorg-vr requested review from bmesuere and niknetniko and removed request for a team January 30, 2023 15:05
@chvp chvp self-requested a review January 30, 2023 15:06
@jorg-vr jorg-vr added the deploy mestra Request a deployment on mestra label Jan 31, 2023
@jorg-vr jorg-vr temporarily deployed to mestra January 31, 2023 08:17 — with GitHub Actions Inactive
@github-actions github-actions bot removed the deploy mestra Request a deployment on mestra label Jan 31, 2023
app/assets/javascripts/code_listing/question_annotation.ts Outdated Show resolved Hide resolved
app/assets/javascripts/notification.ts Outdated Show resolved Hide resolved
@jorg-vr jorg-vr requested a review from bmesuere January 31, 2023 09:58
Copy link
Member

@bmesuere bmesuere left a comment

Choose a reason for hiding this comment

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

This is a lot more readable! 👍

@jorg-vr jorg-vr merged commit 6452161 into develop Jan 31, 2023
@jorg-vr jorg-vr deleted the chore/tweak-notifications branch January 31, 2023 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Repository/build/dependency maintenance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tweak notification fetch frequency
4 participants