class TeamCachedCounts
Public Class Methods
Source
# File app/lib/team_cached_counts.rb, line 4 def initialize(team) @team = team end
Public Instance Methods
Source
# File app/lib/team_cached_counts.rb, line 8 def import_issues return nil if current_user.nil? Rails .cache .fetch(import_issues_key) do vaccination_records_with_issues = VaccinationRecordPolicy::Scope .new(current_user, VaccinationRecord) .resolve .with_pending_changes .pluck(:patient_id) patients_with_issues = PatientPolicy::Scope .new(current_user, Patient) .resolve .with_pending_changes_for_team(team:) .pluck(:id) (vaccination_records_with_issues + patients_with_issues).uniq.length end end
Source
# File app/lib/team_cached_counts.rb, line 68 def reset_all! reset_import_issues! reset_school_moves! reset_unmatched_consent_responses! end
Source
# File app/lib/team_cached_counts.rb, line 32 def reset_import_issues! Rails.cache.delete(import_issues_key) end
Source
# File app/lib/team_cached_counts.rb, line 46 def reset_school_moves! Rails.cache.delete(school_moves_key) end
Source
# File app/lib/team_cached_counts.rb, line 64 def reset_unmatched_consent_responses! Rails.cache.delete(unmatched_consent_responses_key) end
Source
# File app/lib/team_cached_counts.rb, line 36 def school_moves return nil if current_user.nil? Rails .cache .fetch(school_moves_key) do SchoolMovePolicy::Scope.new(current_user, SchoolMove).resolve.count end end
Source
# File app/lib/team_cached_counts.rb, line 50 def unmatched_consent_responses return nil if current_user.nil? Rails .cache .fetch(unmatched_consent_responses_key) do ConsentFormPolicy::Scope .new(current_user, ConsentForm) .resolve .unmatched .count end end