File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
frameworks/Ruby/roda-sequel Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change 3
3
require "time"
4
4
require "oj"
5
5
MAX_PK = 10_000
6
+ QUERY_RANGE = ( 1 ..MAX_PK ) . freeze
7
+ ALL_IDS = QUERY_RANGE . to_a
6
8
QUERIES_MIN = 1
7
9
QUERIES_MAX = 500
8
10
SEQUEL_NO_ASSOCIATIONS = true
Original file line number Diff line number Diff line change @@ -37,7 +37,9 @@ def rand1
37
37
r . is "queries" do
38
38
worlds =
39
39
DB . synchronize do
40
- Array . new ( bounded_queries ) { World . with_pk ( rand1 ) . values }
40
+ ALL_IDS . sample ( bounded_queries ) . map do |id |
41
+ World . with_pk ( id ) . values
42
+ end
41
43
end
42
44
worlds . to_json
43
45
end
@@ -58,8 +60,8 @@ def rand1
58
60
r . is "updates" do
59
61
worlds =
60
62
DB . synchronize do
61
- Array . new ( bounded_queries ) do
62
- world = World . with_pk ( rand1 )
63
+ ALL_IDS . sample ( bounded_queries ) . map do | id |
64
+ world = World . with_pk ( id )
63
65
new_value = rand1
64
66
new_value = rand1 while new_value == world . randomnumber
65
67
world . update ( randomnumber : new_value )
You can’t perform that action at this time.
0 commit comments