Module: Request::Statistics
- Included in:
- Request
- Defined in:
- app/models/request/statistics.rb
Defined Under Namespace
Instance Method Summary collapse
-
#asset_statistics(wheres) ⇒ Object
rubocop:todo Metrics/MethodLength.
-
#progress_statistics ⇒ Object
Returns a hash that maps from the RequestType to the information about the number of requests in various states.
-
#sample_statistics_new ⇒ Object
rubocop:todo Metrics/MethodLength.
Instance Method Details
#asset_statistics(wheres) ⇒ Object
rubocop:todo Metrics/MethodLength
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'app/models/request/statistics.rb', line 93 def asset_statistics(wheres) # rubocop:todo Metrics/AbcSize counters = select('asset_id,request_type_id,state, count(*) as total') .group('asset_id, request_type_id, state') .includes(:request_type) .where(wheres) tabulated = Hash.new { |h, k| h[k] = Summary.new } tabulated.tap do counters.each do |asset_request_type_state_count| tabulated[asset_request_type_state_count.asset_id.to_i][asset_request_type_state_count.request_type_id.to_i][ asset_request_type_state_count.state ] = asset_request_type_state_count.total.to_i end end end |
#progress_statistics ⇒ Object
Returns a hash that maps from the RequestType to the information about the number of requests in various states. This is effectively summary data that can be displayed in a tabular format for the user.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'app/models/request/statistics.rb', line 77 def progress_statistics # rubocop:todo Metrics/MethodLength counters = select('request_type_id, state, count(distinct requests.id) as total').group('request_type_id, state').includes( :request_type ) tabulated = Hash.new { |h, k| h[k] = Counter.new } tabulated.tap do counters.each do |request_type_state_count| tabulated[request_type_state_count.request_type][ request_type_state_count.state ] = request_type_state_count.total.to_i end end end |
#sample_statistics_new ⇒ Object
rubocop:todo Metrics/MethodLength
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'app/models/request/statistics.rb', line 112 def sample_statistics_new # rubocop:todo Metrics/AbcSize counters = join_asset .select('sample_id,request_type_id,state,count(*) as total') .group('sample_id, request_type_id, state') .includes(:request_type) tabulated = Hash.new { |h, k| h[k] = Summary.new } tabulated.tap do counters.each do |sample_request_type_state_count| tabulated[sample_request_type_state_count.sample_id.to_i][sample_request_type_state_count.request_type_id.to_i][ sample_request_type_state_count.state ] = sample_request_type_state_count.total.to_i end end end |