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

[E] optimized getMyGroups() #2071

Merged
merged 1 commit into from
Jan 23, 2022

Conversation

githubertus
Copy link
Contributor

same logic again:
if user is approved, it needs no extra isMember() check

same logic again:
if user is approved, it needs no extra isMember() check
@githubertus
Copy link
Contributor Author

allthough db queries are a bit reduced now
this one still gives me a headache because we're running in here with every bootchat cycle
only to get those group entries in the left sidebar one time

should find a way to move that ossn_get_user_groups() call outside of group init to a page load callback ...

@lianglee
Copy link
Member

allthough db queries are a bit reduced now this one still gives me a headache because we're running in here with every bootchat cycle only to get those group entries in the left sidebar one time

should find a way to move that ossn_get_user_groups() call outside of group init to a page load callback ...

I think we can use the Session and store user group in session and each time loading from session instead of DB and we can add a hook or in action file if new group added by user we can update session. Maybe this is bad idea but that is only possible thing I can think of ;)

@githubertus
Copy link
Contributor Author

Yeah, storing in session would be the only way to call it only ONCE,

What I just tried successfully instead is:

function ossn_view_sections_menu($menu, $type = 'frontend') {
error_log('VIEW SECTIONS');
ossn_trigger_callback('sections_menu', 'add:entries', null);
return ossn_view_menu($menu, "menus/sections/{$menu}");
}

and in Groups com file
ossn_register_callback('sections_menu', 'add:entries', 'ossn_group_sidebar_entries');
and moving the complete group menu registering inside that callback function.

Since ossn_view_sections_menu() gets only called on HTML page loads,
this would at least prevent to retrieve the user groups again and again with every XHR request
and this way reduce db queries massively as long as the user stays on the same page. :)

@lianglee
Copy link
Member

lianglee commented Jan 23, 2022 via email

@lianglee lianglee merged commit 71e1f31 into opensource-socialnetwork:v6.x Jan 23, 2022
@lianglee lianglee changed the title optimized getMyGroups() [E] optimized getMyGroups() Jan 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants