Skip to content
This repository has been archived by the owner on Nov 13, 2021. It is now read-only.

Corrected returned value of EvaluationMethods#evaluators_for method #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

neilmarion
Copy link

Running @answer.evaluators_for(:answer_reputation) in console

invokes

ReputationSystem::Evaluation Load (0.6ms)  SELECT "rs_evaluations".* FROM "rs_evaluations" WHERE "rs_evaluations"."target_id" = 131 AND "rs_evaluations"."target_type" = 'Answer' AND "rs_evaluations"."reputation_name" = 'answer_reputation'

It returns Evaluations not evaluators (in my case 'users') as opposed to the wiki.

#56

@kn
Copy link

kn commented May 20, 2013

Hi @neilmarion

Thank you for the PR.

I don't quite understand why your sql query looks like that. If you take a look at the line you removed:

self.evaluations.for(srn).includes(:source).map(&:source)

It is getting evaluators, i.e. source. And the spec is passing (line 89).

Therefore, I'm not convinced this is a bug in the gem yet. Please double check if this is a bug belongs to the gem or your application.

(By the way, your code is not generic enough. It is assuming a source is User.)

@neilmarion
Copy link
Author

Sorry for the non-generic code. I was probably in a hurry when I did the PR.

Here's how my code look like (involving your gem)

User https://github.com/neilmarion/paano/blob/master/app/models/user.rb

class User < ActiveRecord::Base
  has_many :evaluations, class_name: "RSEvaluation", as: :source

  has_reputation :karma,
    :source => [
      {:reputation => :questioning_skill},
      {:reputation => :answering_skill} ]

  has_reputation :answering_skill,
    :source => { :reputation => :answer_reputation, :of => :answers}

  has_reputation :questioning_skill,
    :source => { :reputation => :question_reputation, :of => :questions}
end

Post https://github.com/neilmarion/paano/blob/master/app/models/post.rb

class Post < ActiveRecord::Base

end

Question https://github.com/neilmarion/paano/blob/master/app/models/question.rb

class Question < Post

  has_many :evaluations, class_name: "RSEvaluation", as: :source
  has_reputation :question_reputation, :source => :user, :source_of => { reputation: :questioning_skill, of: :user }
end

Answer https://github.com/neilmarion/paano/blob/master/app/models/answer.rb

Answer < Post
  has_many :evaluations, class_name: "RSEvaluation", as: :source
  has_reputation :answer_reputation, :source => :user, :source_of => { reputation: :answering_skill, of: :user }
end

I feel like I've done everything already to decode your gem. I've actually encountered so many bugs along with using your library. Sorry to have come to a conclusion that your gem is the fault. By the way, this trouble may be caused by the fact that my Post-Question-Answer models are using STI.

Will be glad if you could help me sort this out. Thanks!

@CLAassistant
Copy link

CLAassistant commented Jul 18, 2019

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Neil Marion dela Cruz seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants