M forms/sim_details.rb => forms/sim_details.rb +6 -1
@@ 1,4 1,9 @@
result!
title "(e)SIM Details"
-table(@sims, iccid: "ICCID", remaining_usage_mb: "MB Remaining")
+table(
+ @sims,
+ iccid: "ICCID",
+ remaining_usage_mb: "MB Remaining",
+ nickname: "Nickname"
+)
M lib/sim.rb => lib/sim.rb +1 -0
@@ 9,6 9,7 @@ class SIM
remaining_usage_kb Integer
remaining_days Integer
notes String
+ nickname Either(String, nil), default: nil
end
def self.extract(kwargs)
M lib/sim_repo.rb => lib/sim_repo.rb +4 -2
@@ 26,10 26,12 @@ class SIMRepo
def owned_by(customer)
customer = customer.customer_id if customer.respond_to?(:customer_id)
promise = db.query_defer(<<~SQL, [customer])
- SELECT iccid FROM sims WHERE customer_id=$1
+ SELECT iccid, nickname FROM sims WHERE customer_id=$1
SQL
promise.then { |result|
- EMPromise.all(result.map { |row| find(row["iccid"]) })
+ EMPromise.all(result.map { |row|
+ find(row["iccid"]).then { |sim| sim.with(nickname: row["nickname"]) }
+ })
}
end
end
M schemas => schemas +1 -1
@@ 1,1 1,1 @@
-Subproject commit a449672f5cad37e63e6339e4577ed27ff8289df9
+Subproject commit a9f8b83487140f91fc8da3a3de99f5f28aa060b9
M test/test_sim_repo.rb => test/test_sim_repo.rb +2 -1
@@ 7,7 7,7 @@ class SIMRepoTest < Minitest::Test
def setup
@repo = SIMRepo.new(
db: FakeDB.new(
- ["test"] => [{ "iccid" => "1234" }]
+ ["test"] => [{ "iccid" => "1234", "nickname" => "My Cool SIM" }]
)
)
end
@@ 33,6 33,7 @@ class SIMRepoTest < Minitest::Test
sims = @repo.owned_by("test").sync
assert_equal 1, sims.length
assert_equal "1234", sims[0].iccid
+ assert_equal "My Cool SIM", sims[0].nickname
assert_requested req
end
em :test_owned_by