Skip to content

Commit 5fa7af5

Browse files
committed
[ruby/rack-sequel] Get ids outside of database connection
+---------------------------+-----+ | branch_name|query| +---------------------------+-----+ | master|21337| |rack/ids-outside-connection|21873| +---------------------------+-----+
1 parent 8ad55f9 commit 5fa7af5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

frameworks/Ruby/rack-sequel/hello_world.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ def db
4444
end
4545

4646
def queries(env)
47+
ids = ALL_IDS.sample(bounded_queries(env))
4748
DB.synchronize do
48-
ALL_IDS.sample(bounded_queries(env)).map do |id|
49+
ids.map do |id|
4950
World::BY_ID.(id: id)
5051
end
5152
end
@@ -93,9 +94,10 @@ def fortunes
9394
end
9495

9596
def updates(env)
97+
ids = ALL_IDS.sample(bounded_queries(env))
9698
DB.synchronize do
9799
worlds =
98-
ALL_IDS.sample(bounded_queries(env)).map do |id|
100+
ids.map do |id|
99101
world = World::BY_ID.(id: id)
100102
world[:randomnumber] = rand1
101103
world

0 commit comments

Comments
 (0)