Skip to content

Commit c45982e

Browse files
committed
wip
1 parent ada89a4 commit c45982e

File tree

12 files changed

+121
-25
lines changed

12 files changed

+121
-25
lines changed

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,14 @@ gem "jwt"
4848
gem "mechanize"
4949
gem "notifications-ruby-client"
5050
gem "okcomputer"
51-
gem "omniauth_openid_connect"
5251
gem "omniauth-rails_csrf_protection"
52+
gem "omniauth_openid_connect"
5353
gem "pagy"
5454
gem "phonelib"
5555
gem "pundit"
5656
gem "rails_semantic_logger"
5757
gem "rainbow"
58+
gem "redis"
5859
gem "ruby-progressbar"
5960
gem "rubyzip"
6061
gem "sentry-rails"

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,8 @@ GEM
520520
erb
521521
psych (>= 4.0.0)
522522
redcarpet (3.6.1)
523+
redis (5.4.1)
524+
redis-client (>= 0.22.0)
523525
redis-client (0.25.3)
524526
connection_pool
525527
redis-prescription (2.6.0)
@@ -825,6 +827,7 @@ DEPENDENCIES
825827
rails (~> 8.0.3)
826828
rails_semantic_logger
827829
rainbow
830+
redis
828831
rladr
829832
rspec
830833
rspec-html-matchers

app/controllers/api/testing/teams_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ def destroy
6767
VaccinationRecord.where(performed_ods_code: team.organisation.ods_code)
6868
)
6969

70+
TeamCachedCounts.new(team).reset_all!
71+
7072
unless keep_itself
7173
log_destroy(Session.where(team:))
7274

app/controllers/consent_forms_controller.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ def edit_match
3535
def update_match
3636
@consent_form.match_with_patient!(@patient, current_user:)
3737

38+
reset_count!
39+
3840
session =
3941
@patient
4042
.sessions
@@ -108,6 +110,8 @@ def create_patient
108110
school_move.confirm!
109111

110112
@consent_form.match_with_patient!(patient, current_user:)
113+
114+
reset_count!
111115
end
112116

113117
if patient.nhs_number.nil?
@@ -143,4 +147,8 @@ def set_patient
143147
def archive_params
144148
params.expect(consent_form: :notes).merge(archived_at: Time.current)
145149
end
150+
151+
def reset_count!
152+
TeamCachedCounts.new(current_team).reset_unmatched_consent_responses!
153+
end
146154
end

app/controllers/imports/issues_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ def set_patient
7070
def set_form
7171
apply_changes = params.dig(:import_duplicate_form, :apply_changes)
7272

73-
@form = ImportDuplicateForm.new(object: @record, apply_changes:)
73+
@form =
74+
ImportDuplicateForm.new(current_team:, object: @record, apply_changes:)
7475
end
7576

7677
def set_type

app/controllers/parent_interface/consent_forms_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ def record
5555

5656
session.delete(:consent_form_id)
5757

58+
TeamCachedCounts.new(@team).reset_unmatched_consent_responses!
59+
5860
send_consent_form_confirmation(@consent_form)
5961

6062
ConsentFormMatchingJob.perform_later(@consent_form)

app/forms/import_duplicate_form.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class ImportDuplicateForm
44
include ActiveModel::Model
55

6-
attr_accessor :object, :apply_changes
6+
attr_accessor :current_team, :object, :apply_changes
77

88
validates :apply_changes, inclusion: { in: :apply_changes_options }
99

@@ -21,6 +21,8 @@ def save
2121
end
2222
end
2323

24+
reset_count!
25+
2426
true
2527
rescue ActiveRecord::RecordInvalid
2628
errors.add(:base, "Failed to save changes")
@@ -64,4 +66,8 @@ def discard_pending_changes!
6466
def keep_both_changes!
6567
object.apply_pending_changes_to_new_record! if can_keep_both? && can_apply?
6668
end
69+
70+
def reset_count!
71+
TeamCachedCounts.new(current_team).reset_import_issues!
72+
end
6773
end

app/forms/school_move_form.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ def save
2020
@school_move.ignore!
2121
end
2222

23+
TeamCachedCounts.new(team).reset_school_moves!
24+
2325
true
2426
end
27+
28+
private
29+
30+
def team = current_user.selected_team
2531
end

app/jobs/commit_patient_changesets_job.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ def perform(import)
2929

3030
import.postprocess_rows!
3131

32+
reset_counts(import)
33+
3234
import.update_columns(
3335
processed_at: Time.zone.now,
3436
status: :processed,
@@ -186,4 +188,10 @@ def has_auto_confirmable_school_move?(school_move, import)
186188
academic_year: import.academic_year
187189
) || school_move.patient.archived?(team: import.team)
188190
end
191+
192+
def reset_counts(import)
193+
cached_counts = TeamCachedCounts.new(import.team)
194+
cached_counts.reset_import_issues!
195+
cached_counts.reset_school_moves!
196+
end
189197
end

app/jobs/consent_form_matching_job.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def match_with_exact_nhs_number
6565
patient.update_from_pds!(pds_patient)
6666
send_parental_contact_warning_if_needed(patient, @consent_form)
6767
@consent_form.match_with_patient!(patient, current_user: nil)
68+
reset_counts
69+
true
6870
end
6971

7072
def location_patients
@@ -106,5 +108,10 @@ def match_patient(patient)
106108

107109
send_parental_contact_warning_if_needed(patient, @consent_form)
108110
@consent_form.match_with_patient!(patient, current_user: nil)
111+
reset_counts
112+
end
113+
114+
def reset_counts
115+
TeamCachedCounts.new(@consent_form.team).reset_unmatched_consent_responses!
109116
end
110117
end

0 commit comments

Comments
 (0)