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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22a3e944fcb8f4a9e0d862b50321ead38c607a3488c002096735853b06922be5
|
4
|
+
data.tar.gz: fb58caba60b6795e915efaadd08fea81e2817129ef500843da95ba48047028aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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(
|
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
|
-
|
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)
|
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.
|
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-
|
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.
|
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
|