renalware-core 2.0.43 → 2.0.44

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: bb0aa2a964b933379fa9c6a72eb9570f4b6251f4d124fa6377fb2b6083deb8dd
4
- data.tar.gz: bf7030934f456717a02fd899f7dfc530cdbde2e1a62cdaaa640ec268d68033ce
3
+ metadata.gz: 1f0786caf2cbce2b717b9cdac406185a53787547dea6a7e7effed98ed09fdca0
4
+ data.tar.gz: cb9bcf041a6eb26dcad74880db20ae844fdbf5fe4a5cc0b4a5362a849f322a9f
5
5
  SHA512:
6
- metadata.gz: c4348f2ff8acd6513e6dfd056ae78de44655f115f3ed5d56bfed7ee85169958a3a464e59a28af2920698177b018f3ee31b19adc520168dabe9a147160a9883fe
7
- data.tar.gz: 2199399c9b5e3a4dd703c41492c048f59248f02c48b09541925e8baae20cf7c5f58c741368d6e1d21e174d6b16af34e787316379c6535d71d724066ba26aad74
6
+ metadata.gz: bb3f0f9ffadb729f50b5b39ad3f0f067827eee607a29f5254a606b551a21dded6cbebb587bcf9d63d4efd31e35b8fc7962671e5b0be904d790f5193ab2f1bb45
7
+ data.tar.gz: 37b69cc689c4bd52d1ef7b2e3ce241f36e65e767527606d1fe94230ef6c8d12b081eedc762d198aefef252fe0066cc51f2fd3e127052ac583620d0be4cd0af1e
data/app/jobs/feed_job.rb CHANGED
@@ -4,7 +4,7 @@
4
4
  # into the `delayed_jobs` table:
5
5
  #
6
6
  # handler: {see h7_message_example.yml}
7
- # run_at: {current_time}
7
+ # run_at: {current_time e.g. NOW() AT TIME ZONE 'UTC'}
8
8
  #
9
9
  # Notes:
10
10
  #
@@ -15,7 +15,26 @@ FeedJob = Struct.new(:raw_message) do
15
15
  def perform
16
16
  Renalware::Feeds
17
17
  .message_processor
18
- .broadcasting_to_configured_subscribers
19
18
  .call(raw_message)
20
19
  end
20
+
21
+ def max_attempts
22
+ 4
23
+ end
24
+
25
+ def destroy_failed_jobs?
26
+ false
27
+ end
28
+
29
+ # Reschedule after an error. No point trying straight away, so try at these intervals:
30
+ # After attempt no. Wait for hours
31
+ # ---------------------------
32
+ # 1 2
33
+ # 2 17
34
+ # 3 82
35
+ # Then give up.
36
+ # Note e.g. attempts**4 == attempts to the power of 4 == 81
37
+ def reschedule_at(current_time, attempts)
38
+ current_time + ((attempts**4) + 1).hours
39
+ end
21
40
  end
@@ -7,6 +7,8 @@ require "month_period"
7
7
  module Renalware
8
8
  module HD
9
9
  class GenerateMonthlyStatistics < ApplicationJob
10
+ queue_as :hd_patient_statistics
11
+ queue_with_priority 1
10
12
  attr_reader :period
11
13
 
12
14
  def initialize(month: nil, year: nil)
@@ -5,6 +5,7 @@ require "month_period"
5
5
  module Renalware
6
6
  module HD
7
7
  class GenerateMonthlyStatisticsForPatientJob < ApplicationJob
8
+ queue_with_priority 2
8
9
  queue_as :hd_patient_statistics
9
10
 
10
11
  # :reek:UtilityFunction
@@ -7,6 +7,7 @@ module Renalware
7
7
  module HD
8
8
  class UpdateRollingPatientStatisticsJob < ApplicationJob
9
9
  queue_as :hd_patient_statistics
10
+ queue_with_priority 1
10
11
 
11
12
  # :reek:UtilityFunction
12
13
  def perform(patient)
@@ -5,7 +5,12 @@ require "fileutils"
5
5
 
6
6
  module Renalware
7
7
  module Letters
8
+ # Used for example in a host app like renalware-kch to generate a PDF letter for saving to
9
+ # the electronic public register
8
10
  class SavePdfLetterToFileJob < ApplicationJob
11
+ queue_as :pdf_generation
12
+ queue_with_priority 1
13
+
9
14
  def perform(letter:, file_path:)
10
15
  file_path = Pathname(file_path)
11
16
  create_folder_if_not_exists(file_path)
@@ -6,6 +6,7 @@ module Renalware
6
6
  module Reporting
7
7
  class RefreshAuditDataJob < ApplicationJob
8
8
  queue_as :reporting
9
+ queue_with_priority 1
9
10
 
10
11
  # :reek:UtilityFunction
11
12
  def perform(audit)
@@ -38,6 +38,7 @@ module Renalware
38
38
 
39
39
  def sanitize_query(query)
40
40
  query
41
+ .to_s
41
42
  .strip
42
43
  .tr(",", " ")
43
44
  .gsub(" ", " ")
@@ -15,10 +15,14 @@ module Renalware
15
15
  @message_processor ||= build_message_processor
16
16
  end
17
17
 
18
+ # Note we are using both the SubscriptionRegistry (which we think is not thread safe)
19
+ # as does not store the registry in TLS (?) and also the newer subscription_map
20
+ # We need to consolidate these.
18
21
  def build_message_processor
19
22
  SubscriptionRegistry
20
23
  .instance
21
24
  .subscribe_listeners_to(MessageProcessor.new)
25
+ .broadcasting_to_configured_subscribers
22
26
  end
23
27
  end
24
28
  end
@@ -51,7 +51,9 @@ module Renalware
51
51
  attribute :bowel_disease_notes
52
52
  attribute :added_comments
53
53
 
54
- validates :assessed_on, presence: true
54
+ validates :assessed_on, presence: true, timeliness: { type: :date }
55
+ validates :home_visit_on, timeliness: { type: :date, allow_blank: true }
56
+ validates :access_clinic_on, timeliness: { type: :date, allow_blank: true }
55
57
  end
56
58
  has_document
57
59
  end
@@ -23,8 +23,8 @@ article.pd_assessments
23
23
  - if policy(assessment).show?
24
24
  = link_to("View", [patient, assessment])
25
25
  td= l(assessment.created_at)
26
- td= l(document.assessed_on)
26
+ td= document.assessed_on.is_a?(Date) ? l(document.assessed_on) : document.assessed_on
27
27
  td= document.assessor
28
28
  td= document.had_home_visit&.text
29
- td= l(document.home_visit_on)
29
+ td= document.home_visit_on.is_a?(Date) ? l(document.home_visit_on) : document.home_visit_on
30
30
  td
@@ -8,10 +8,10 @@
8
8
  article.pd_assessment_document
9
9
  header
10
10
  = definition_list_for(assessment.document, size: :xlarge) do |list|
11
- = list.definition(:assessed_on) { |value| l(value) }
11
+ = list.definition(:assessed_on) { |value| value.is_a?(Date) ? l(value) : value }
12
12
  = list.definition(:assessor)
13
13
  = list.definition(:had_home_visit, &:text)
14
- = list.definition(:home_visit_on) { |value| l(value) }
14
+ = list.definition(:home_visit_on) { |value| value.is_a?(Date) ? l(value) : value }
15
15
  = list.definition(:housing_type, &:text)
16
16
  = list.definition(:occupant_notes)
17
17
  = list.definition(:exchange_area)
@@ -37,7 +37,7 @@
37
37
  = list.definition(:insertion_discussed, &:text)
38
38
  = list.definition(:method_chosen, &:text)
39
39
  = list.definition(:access_clinic_referral, &:text)
40
- = list.definition(:access_clinic_on) { |value| l(value) }
40
+ = list.definition(:access_clinic_on) { |value| value.is_a?(Date) ? l(value) : value }
41
41
  = list.definition(:abdo_assessor)
42
42
  = list.definition(:bowel_disease, &:text)
43
43
  = list.definition(:bowel_disease_notes)
@@ -2,5 +2,10 @@
2
2
 
3
3
  Delayed::Worker.logger = Logger.new(Rails.root.join("log", "delayed_job.log"))
4
4
  Delayed::Worker.destroy_failed_jobs = false
5
- Delayed::Worker.max_attempts = 10
6
- Delayed::Worker.max_run_time = 4.hours
5
+ Delayed::Worker.max_attempts = 10 # overridden e.g. in FeedJob
6
+ Delayed::Worker.max_run_time = 2.hours
7
+ Delayed::Worker.read_ahead = 10
8
+ Delayed::Worker.sleep_delay = 15 # Also affects how long it takes delayed_job to stop on Crl+C
9
+ Delayed::Worker.default_priority = 5 # use a lower number to get preferential treatment
10
+ # Will only raise an exception on TERM signals but INT will wait for the current job to finish.
11
+ Delayed::Worker.raise_signal_exceptions = :term
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Renalware
4
- VERSION = "2.0.43"
4
+ VERSION = "2.0.44"
5
5
  end
@@ -4,6 +4,7 @@ FactoryBot.define do
4
4
  factory :internal_message, class: "Renalware::Messaging::Internal::Message" do
5
5
  body { "The body" }
6
6
  subject { "The subject" }
7
+
7
8
  urgent { false }
8
9
  association :author, factory: :author
9
10
  sent_at { Time.zone.now }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: renalware-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.43
4
+ version: 2.0.44
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airslie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-20 00:00:00.000000000 Z
11
+ date: 2018-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_type