Skip to content

Instantly share code, notes, and snippets.

@eduardojunio
Last active July 23, 2021 21:01
Show Gist options
  • Save eduardojunio/fc634a1e6f916b73f78e0268dce94075 to your computer and use it in GitHub Desktop.
Save eduardojunio/fc634a1e6f916b73f78e0268dce94075 to your computer and use it in GitHub Desktop.
Proof of concept on how we could implement the new metrics on the Flow::Statistics class
class Flow::Statistics
def patients_messaged
CacheCounter.get_fast_count_for(Flow::FlowPatient, flow.provider_id, :patients) -
pre_filtered_flow_patients.where.not(state: %w(duplicated incomplete)).count
end
def need_review
pre_filtered_flow_patients.last_response_flagged("invalid").count
end
def opt_out_rate
pre_filtered_flow_patients.opted_out.count / patients_messaged
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment