Skip to content

Conversation

@leanhthang
Copy link

When use devise_token_auth_group the method 'set_user_by_token' has been call multi times per mapping name. so that, resource has found not reused. That will Increase performance.

Copy link
Collaborator

@MaicolBen MaicolBen left a comment

Choose a reason for hiding this comment

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

Thanks for adding the tests

# user auth
def set_user_by_token(mapping = nil)
# Avoid checking resources multi times
return @resource if resource_is_checked?(mapping)
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we just use defined?(@resource) instead of this elaborate check?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agreed

Copy link
Author

@leanhthang leanhthang Jan 28, 2021

Choose a reason for hiding this comment

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

If you want instead by defined?(@resource) that is similar return @resource if @resource
And, I'm try set return @resource if defined?(@resource), It works fine when logged in.
But, when not yet logged in it still check resources many times.
Screenshot from 2021-01-28 10-49-23

@leanhthang leanhthang force-pushed the fix_checking_resource_muti_times branch 3 times, most recently from bd7242f to 0968c7a Compare January 28, 2021 03:43
@leanhthang leanhthang force-pushed the fix_checking_resource_muti_times branch from 0968c7a to c176baf Compare February 17, 2021 10:51
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.

4 participants