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

About query and performance #42

Open
soyoh opened this issue Jul 1, 2013 · 0 comments
Open

About query and performance #42

soyoh opened this issue Jul 1, 2013 · 0 comments

Comments

@soyoh
Copy link

soyoh commented Jul 1, 2013

Hello,
first of all, thanks for your work, is a nice gem, i'm plaining to use it in several projects im planing.

just playing with it on the console, i find that there are too much querys, heres is an example.

  1. user A invites user B
  2. user B accepts user A invitation

userB.appove(userA)

this method, located at active_record_friend_model (:67) use another method to find if there is a friendship record between these two users "find_any_friendship_with(userA)"
but, under this line, there is another mehod that do the same "invited?(:156)" that also uses "find_any_friendship_with", what about if we just do one query?? maybe the method can just be like this:

  def approve(user)
    friendship = find_any_friendship_with(user)
    return false if friendship.nil?
    friendship.update_attribute(:pending, false)
  end

i'm new on ruby, maybe i'm missing something....

thanks!!!

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

No branches or pull requests

1 participant