Class: AnalysisUserDecision
- Inherits:
-
Object
- Object
- AnalysisUserDecision
- Defined in:
- lib/analysis_user_decision.rb
Overview
Information about decisions taken by an user, on a systematic review of a specific stage
Instance Attribute Summary collapse
-
#assignations ⇒ Object
readonly
Raw dataset of AllocationCd.
-
#decision_by_cd ⇒ Object
readonly
Decision for each assignment.
-
#decisions ⇒ Object
readonly
Raw dataset of Decision.
-
#total_decisions ⇒ Object
readonly
Number of document for each type of decision.
Instance Method Summary collapse
- #allocated_to_cd_id(cd_id) ⇒ Object
- #canonical_documents ⇒ Object
- #decision_cd_id(cd_id) ⇒ Object
- #have_allocations? ⇒ Boolean
-
#initialize(rs_id, user_id, stage) ⇒ AnalysisUserDecision
constructor
A new instance of AnalysisUserDecision.
-
#procesar_cd_ids ⇒ Object
Define @cd_ids.
- #process_basic_indicators ⇒ Object
-
#systematic_review ⇒ Object
procesar_numero_citas.
Constructor Details
#initialize(rs_id, user_id, stage) ⇒ AnalysisUserDecision
Returns a new instance of AnalysisUserDecision.
40 41 42 43 44 45 46 47 48 |
# File 'lib/analysis_user_decision.rb', line 40 def initialize(rs_id,user_id,stage) @rs_id=rs_id @user_id=user_id @stage=stage.to_s @assignations=nil? procesar_cd_ids process_basic_indicators #procesar_numero_citas end |
Instance Attribute Details
#assignations ⇒ Object (readonly)
Raw dataset of AllocationCd
39 40 41 |
# File 'lib/analysis_user_decision.rb', line 39 def assignations @assignations end |
#decision_by_cd ⇒ Object (readonly)
Decision for each assignment
35 36 37 |
# File 'lib/analysis_user_decision.rb', line 35 def decision_by_cd @decision_by_cd end |
#decisions ⇒ Object (readonly)
Raw dataset of Decision
33 34 35 |
# File 'lib/analysis_user_decision.rb', line 33 def decisions @decisions end |
#total_decisions ⇒ Object (readonly)
Number of document for each type of decision
37 38 39 |
# File 'lib/analysis_user_decision.rb', line 37 def total_decisions @total_decisions end |
Instance Method Details
#allocated_to_cd_id(cd_id) ⇒ Object
58 59 60 |
# File 'lib/analysis_user_decision.rb', line 58 def allocated_to_cd_id(cd_id) @cd_ids.include? cd_id.to_i end |
#canonical_documents ⇒ Object
52 53 54 |
# File 'lib/analysis_user_decision.rb', line 52 def canonical_documents CanonicalDocument.where(:id=>@cd_ids) end |
#decision_cd_id(cd_id) ⇒ Object
61 62 63 |
# File 'lib/analysis_user_decision.rb', line 61 def decision_cd_id(cd_id) @decision_by_cd[cd_id] end |
#have_allocations? ⇒ Boolean
55 56 57 |
# File 'lib/analysis_user_decision.rb', line 55 def have_allocations? !@assignations.empty? end |
#procesar_cd_ids ⇒ Object
Define @cd_ids. Si no se han asignado, los toma todos Si existen asignaciones, sólo se consideran estas
66 67 68 69 70 71 72 73 74 |
# File 'lib/analysis_user_decision.rb', line 66 def procesar_cd_ids cd_stage=systematic_review.cd_id_by_stage(@stage) @assignations=AllocationCd.where(:systematic_review_id=>@rs_id, :user_id=>@user_id, :canonical_document_id=>cd_stage, :stage=>@stage) if @assignations.empty? @cd_ids=[] else @cd_ids=@assignations.select_map(:canonical_document_id) end end |
#process_basic_indicators ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/analysis_user_decision.rb', line 75 def process_basic_indicators if @cd_ids.empty? @decisions=[] @decision_by_cd={} @total_decisions={} else @decisions=Decision.where(:user_id => @user_id, :systematic_review_id => @rs_id, :stage => @stage, :canonical_document_id=>@cd_ids).as_hash(:canonical_document_id) @decision_by_cd=@cd_ids.inject({}) {|ac, cd_id| dec_id=@decisions[cd_id] dec_dec=dec_id ? dec_id[:decision] : Decision::NO_DECISION dec_dec=Decision::NO_DECISION if dec_dec.nil? ac[cd_id]=dec_dec ac } @total_decisions=@cd_ids.inject({}) {|ac,cd_id| dec=@decision_by_cd[cd_id] dec_i= dec.nil? ? Decision::NO_DECISION : dec ac[ dec_i]||=0 ac[ dec_i]+=1 ac } end end |
#systematic_review ⇒ Object
procesar_numero_citas
49 50 51 |
# File 'lib/analysis_user_decision.rb', line 49 def systematic_review @rs||=SystematicReview[@rs_id] end |