malawi_hiv_program_reports 1.1.17 → 1.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c818eb00df67da231594873c08c20bb5df18a2c53433788a96e27a7ca1211bf9
4
- data.tar.gz: fd99e8c2ca139a33ddd76a9eefbaef20dfcf6eee7c1b6290919e2240c39b9c63
3
+ metadata.gz: 22a3e944fcb8f4a9e0d862b50321ead38c607a3488c002096735853b06922be5
4
+ data.tar.gz: fb58caba60b6795e915efaadd08fea81e2817129ef500843da95ba48047028aa
5
5
  SHA512:
6
- metadata.gz: f61982a9e3ce30521079abacdd89144d6c03d10fde293d5fbefcb61fac57a143e5680f5216eee22e8423f37d8b88014205f602003af0644a7a95078fed7d052c
7
- data.tar.gz: ea196faf6b0a471e995e4885058acbc0a141c7fcbe948e502801648ed796fbea5e72bf1d0f28b556ea0ccd1404cbc78046928ebb5330acdcfd7068f54f16c924
6
+ metadata.gz: 91ae6c317a44e67d502cc97f3d3d72d54ace89d8def8326f8fc2ea7901e1b4693c0754084b33a1bf9c9d32626dd840b72df1e1c56ee558547ed0ff5056756403
7
+ data.tar.gz: 8d52d72581ab43cc207e34bbb20ecf62d942cd104c854e0890c4b1712346d64a609907cd447c9f912298be40b78d0affd36e4be1a8ef123a86f7fd749258a83b
@@ -23,10 +23,7 @@ module MalawiHivProgramReports
23
23
  @definition = kwargs[:definition] || 'pepfar'
24
24
  @iteration = Concurrent::AtomicFixnum.new(0)
25
25
  @start_time = Time.now
26
- @redis = Redis.new
27
- @redis.set('cumulative_progress', 0)
28
- @redis.set('cumulative_status', 'running')
29
- @redis.set('cumulative_time_taken', 0)
26
+ prepare_redis
30
27
  definition = @definition.downcase
31
28
  raise ArgumentError, "Invalid outcomes definition: #{definition}" unless %w[moh pepfar].include?(definition)
32
29
  end
@@ -61,7 +58,7 @@ module MalawiHivProgramReports
61
58
  queue = Queue.new
62
59
  locations.each { |loc| queue << loc }
63
60
 
64
- threads = Array.new(65) do
61
+ threads = Array.new(configured_threads) do
65
62
  Thread.new do
66
63
  until queue.empty?
67
64
  loc = begin
@@ -74,7 +71,7 @@ module MalawiHivProgramReports
74
71
  ActiveRecord::Base.connection_pool.with_connection do
75
72
  process_data loc
76
73
  current_iteration = iteration.increment
77
- # update_progress(current_iteration, locations.size)
74
+ update_progress(current_iteration, locations.size)
78
75
  rescue StandardError => e
79
76
  Rails.logger.info("Error processing location #{loc}: #{e.message}")
80
77
  Rails.logger.info(e.backtrace.join("\n"))
@@ -88,6 +85,22 @@ module MalawiHivProgramReports
88
85
  end
89
86
  # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
90
87
 
88
+ def configured_threads
89
+ threads = ::Utils::ConfigReader.application_read('max_threads')&.to_i
90
+ Rails::logger.info("Max threads: #{threads}")
91
+ threads.positive? ? threads : 60
92
+ rescue StandardError => e
93
+ Rails.logger.info("Error reading max threads: #{e.message}")
94
+ 60
95
+ end
96
+
97
+ def prepare_redis
98
+ @redis = Redis.new
99
+ @redis.set('cumulative_progress', 0)
100
+ @redis.set('cumulative_status', 'running')
101
+ @redis.set('cumulative_time_taken', 0)
102
+ end
103
+
91
104
  # update progress in redis and channel
92
105
  def update_progress(current_iteration, total)
93
106
  percentage = (current_iteration.to_f / total * 100).round(2)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MalawiHivProgramReports
4
- VERSION = '1.1.17'
4
+ VERSION = '1.1.18'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: malawi_hiv_program_reports
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.17
4
+ version: 1.1.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roy Chanunkha
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-25 00:00:00.000000000 Z
11
+ date: 2024-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -191,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
191
  - !ruby/object:Gem::Version
192
192
  version: '0'
193
193
  requirements: []
194
- rubygems_version: 3.5.17
194
+ rubygems_version: 3.4.1
195
195
  signing_key:
196
196
  specification_version: 4
197
197
  summary: Malawi HIV PROGRAM Reports for Ruby on Rails