.rubocop.yml 🔗
@@ -24,7 +24,7 @@ Metrics/AbcSize:
- test/*
Metrics/ParameterLists:
- Max: 6
+ Max: 7
Naming/MethodParameterName:
AllowNamesEndingInNumbers: false
Stephen Paul Weber created
.rubocop.yml | 2 +-
lib/command_list.rb | 2 +-
lib/customer.rb | 4 +++-
lib/customer_repo.rb | 12 ++++++++----
test/test_helper.rb | 4 ++++
5 files changed, 17 insertions(+), 7 deletions(-)
@@ -24,7 +24,7 @@ Metrics/AbcSize:
- test/*
Metrics/ParameterLists:
- Max: 6
+ Max: 7
Naming/MethodParameterName:
AllowNamesEndingInNumbers: false
@@ -18,7 +18,7 @@ class CommandList
args = {
from_jid: from_jid, customer: customer,
tel: customer&.registered? ? customer&.registered?&.phone : nil,
- fwd: customer&.fwd,
+ fwd: customer&.fwd, feature_flags: customer&.feature_flags || [],
payment_methods: []
}
return EMPromise.resolve(args) unless customer&.plan_name
@@ -18,7 +18,7 @@ require_relative "./trivial_backend_sgx_repo"
class Customer
extend Forwardable
- attr_reader :customer_id, :balance, :jid, :tndetails
+ attr_reader :customer_id, :balance, :jid, :tndetails, :feature_flags
alias billing_customer_id customer_id
def_delegators :@plan, :active?, :activate_plan_starting_now, :bill_plan,
@@ -53,6 +53,7 @@ class Customer
plan: CustomerPlan.new(customer_id),
balance: BigDecimal(0),
tndetails: {},
+ feature_flags: [],
sgx: TrivialBackendSgxRepo.new.get(customer_id)
)
@plan = plan
@@ -62,6 +63,7 @@ class Customer
@jid = jid
@balance = balance
@tndetails = tndetails
+ @feature_flags = feature_flags
@sgx = sgx
end
@@ -164,11 +164,15 @@ protected
end
def fetch_redis(customer_id)
- mget(
- "jmp_customer_auto_top_up_amount-#{customer_id}",
- "jmp_customer_monthly_overage_limit-#{customer_id}"
- ).then { |r|
+ EMPromise.all([
+ mget(
+ "jmp_customer_auto_top_up_amount-#{customer_id}",
+ "jmp_customer_monthly_overage_limit-#{customer_id}"
+ ),
+ @redis.smembers("jmp_customer_feature_flags-#{customer_id}")
+ ]).then { |r, flags|
r.transform_keys { |k| k.match(/^jmp_customer_([^-]+)/)[1].to_sym }
+ .merge(feature_flags: flags.map(&:to_sym))
}
end
@@ -258,6 +258,10 @@ class FakeRedis
@values[key]&.size || 0
end
+ def smembers(key)
+ @values[key]&.to_a || []
+ end
+
def expire(_, _); end
def exists(*keys)