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

Added restrictions to show assigned tab #103

Merged
merged 30 commits into from Aug 28, 2020

Conversation

Ahmedgagan
Copy link
Contributor

No description provided.

plugin.rb Outdated
add_to_class(:group, :can_show_assigned_tab?) do
users = User.joins("JOIN group_users gu on users.id=gu.user_id").where("gu.group_id=?", self.id)

users.each do |u|
Copy link
Member

Choose a reason for hiding this comment

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

There might be thousands of users here, so we can't afford to load them into memory and loop over them. We will need to write a single SQL query which does the check.

plugin.rb Outdated Show resolved Hide resolved
@Ahmedgagan
Copy link
Contributor Author

@davidtaylorhq The query worked awesomely😍, learned something new from this😅

@davidtaylorhq
Copy link
Member

Great! Glad it worked 😁

Looks like travis is failing on this. And also we should add an rspec check method to make sure the new query keeps working correctly in future.

@davidtaylorhq davidtaylorhq merged commit cd31a82 into discourse:master Aug 28, 2020
@Ahmedgagan Ahmedgagan deleted the assignment_tab branch April 8, 2021 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants