Module: HCA::RateLimitedSearch
- Defined in:
- lib/hca/rate_limited_search.rb
Class Method Summary collapse
- .combine_traits(user_attributes) ⇒ Object
- .create_rate_limited_searches(user_attributes) ⇒ Object
- .truncate_ssn(ssn) ⇒ Object
Instance Method Summary collapse
- #combine_traits(user_attributes) ⇒ Object private
- #create_rate_limited_searches(user_attributes) ⇒ Object private
- #truncate_ssn(ssn) ⇒ Object private
Class Method Details
.combine_traits(user_attributes) ⇒ Object
11 12 13 |
# File 'lib/hca/rate_limited_search.rb', line 11 def combine_traits(user_attributes) user_attributes.to_h.except(:ssn, :middle_name).values.map(&:downcase).join end |
.create_rate_limited_searches(user_attributes) ⇒ Object
15 16 17 18 |
# File 'lib/hca/rate_limited_search.rb', line 15 def create_rate_limited_searches(user_attributes) ::RateLimitedSearch.create_or_increment_count("ssn:#{truncate_ssn(user_attributes.ssn)}") ::RateLimitedSearch.create_or_increment_count("traits:#{combine_traits(user_attributes)}") end |
.truncate_ssn(ssn) ⇒ Object
7 8 9 |
# File 'lib/hca/rate_limited_search.rb', line 7 def truncate_ssn(ssn) "#{ssn[0..2]}#{ssn[5..8]}" end |
Instance Method Details
#combine_traits(user_attributes) ⇒ Object (private)
11 12 13 |
# File 'lib/hca/rate_limited_search.rb', line 11 def combine_traits(user_attributes) user_attributes.to_h.except(:ssn, :middle_name).values.map(&:downcase).join end |
#create_rate_limited_searches(user_attributes) ⇒ Object (private)
15 16 17 18 |
# File 'lib/hca/rate_limited_search.rb', line 15 def create_rate_limited_searches(user_attributes) ::RateLimitedSearch.create_or_increment_count("ssn:#{truncate_ssn(user_attributes.ssn)}") ::RateLimitedSearch.create_or_increment_count("traits:#{combine_traits(user_attributes)}") end |
#truncate_ssn(ssn) ⇒ Object (private)
7 8 9 |
# File 'lib/hca/rate_limited_search.rb', line 7 def truncate_ssn(ssn) "#{ssn[0..2]}#{ssn[5..8]}" end |