Class: Buhos::AnalysisQualityCriteria
- Inherits:
-
Object
- Object
- Buhos::AnalysisQualityCriteria
- Defined in:
- lib/buhos/analysis_quality_criteria.rb
Instance Attribute Summary collapse
-
#cd_ids ⇒ Object
readonly
Returns the value of attribute cd_ids.
-
#criteria ⇒ Object
readonly
Returns the value of attribute criteria.
-
#scale_items ⇒ Object
readonly
Returns the value of attribute scale_items.
-
#sr ⇒ Object
readonly
Returns the value of attribute sr.
Instance Method Summary collapse
-
#initialize(sr) ⇒ AnalysisQualityCriteria
constructor
A new instance of AnalysisQualityCriteria.
- #proportion_by_cd ⇒ Object
Constructor Details
#initialize(sr) ⇒ AnalysisQualityCriteria
Returns a new instance of AnalysisQualityCriteria.
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/buhos/analysis_quality_criteria.rb', line 36 def initialize(sr) @sr=sr @criteria=SrQualityCriterion.join(:quality_criteria, id: :quality_criterion_id).where(systematic_review_id:@sr.id).order(:order) set_canonical_documents @criteria_id=@criteria.map(:quality_criterion_id) @users_id=@sr.group_users.map(&:id) @user_n=@users_id.length @cd_criteria=CdQualityCriterion.where(systematic_review_id:@sr.id, quality_criterion_id: @criteria_id, canonical_document_id:@cd_ids).order(:user_id, :canonical_document_id, :quality_criterion_id) @scale_items=ScalesItem.join(:scales, id: :scale_id).select_all(:scales_items).where(scale_id: @criteria.map {|v| v[:scale_id]}.uniq ).to_hash_groups(:scale_id) end |
Instance Attribute Details
#cd_ids ⇒ Object (readonly)
Returns the value of attribute cd_ids.
34 35 36 |
# File 'lib/buhos/analysis_quality_criteria.rb', line 34 def cd_ids @cd_ids end |
#criteria ⇒ Object (readonly)
Returns the value of attribute criteria.
33 34 35 |
# File 'lib/buhos/analysis_quality_criteria.rb', line 33 def criteria @criteria end |
#scale_items ⇒ Object (readonly)
Returns the value of attribute scale_items.
35 36 37 |
# File 'lib/buhos/analysis_quality_criteria.rb', line 35 def scale_items @scale_items end |
#sr ⇒ Object (readonly)
Returns the value of attribute sr.
32 33 34 |
# File 'lib/buhos/analysis_quality_criteria.rb', line 32 def sr @sr end |
Instance Method Details
#proportion_by_cd ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/buhos/analysis_quality_criteria.rb', line 52 def proportion_by_cd crit_perc=lambda {@criteria.inject({}) { |ac,criterion| ac[criterion[:id]]=@scale_items[criterion[:scale_id]].inject({}) do |ac2,v2| ac2[v2[:value]]=0 ac2 end ac }} percents=@cd_ids.inject({}) do |ac,cd_id| ac[cd_id]=crit_perc.call ac end @cd_criteria.each do |row| percents[row[:canonical_document_id]][row[:quality_criterion_id]][row[:value]]+= 1.to_f/@user_n end percents end |