Module: CustomerServiceIm::Concerns::Customer::ClassMethods
- Defined in:
- app/models/customer_service_im/concerns/customer.rb
Instance Method Summary collapse
- #find_or_create_mp_user(open_id) ⇒ Object
- #online_customer_list_in_redis ⇒ Object
- #online_customers ⇒ Object
- #online_customers_ids ⇒ Object
- #online_customers_redis_key ⇒ Object
- #redis ⇒ Object
Instance Method Details
#find_or_create_mp_user(open_id) ⇒ Object
75 76 77 78 79 80 81 |
# File 'app/models/customer_service_im/concerns/customer.rb', line 75 def find_or_create_mp_user(open_id) return if open_id.blank? User.create_with( email: "#{SecureRandom.uuid}@mp.com", ).find_or_create_by(open_id: open_id) end |
#online_customer_list_in_redis ⇒ Object
71 72 73 |
# File 'app/models/customer_service_im/concerns/customer.rb', line 71 def online_customer_list_in_redis redis.smembers online_customers_redis_key end |
#online_customers ⇒ Object
55 56 57 |
# File 'app/models/customer_service_im/concerns/customer.rb', line 55 def online_customers where(id: online_customers_ids) end |
#online_customers_ids ⇒ Object
59 60 61 |
# File 'app/models/customer_service_im/concerns/customer.rb', line 59 def online_customers_ids online_customer_list_in_redis&.map{|str| str.split("/").second.to_i} end |
#online_customers_redis_key ⇒ Object
67 68 69 |
# File 'app/models/customer_service_im/concerns/customer.rb', line 67 def online_customers_redis_key "#{CustomerServiceIm.appid}_online_customers" end |
#redis ⇒ Object
63 64 65 |
# File 'app/models/customer_service_im/concerns/customer.rb', line 63 def redis @redis ||= Redis.current end |