qfill 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -3
- data/lib/qfill/result.rb +3 -0
- data/lib/qfill/strategy/time_slice.rb +6 -7
- data/lib/qfill/version.rb +1 -1
- data/spec/qfill/manager_spec.rb +34 -9
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebf168a7298dded7f0c9f3eb4e4edd7fd6f6150465a857343c2433eae5861364
|
4
|
+
data.tar.gz: 8917c3a87fdb98aea36a483008d26e46099bae22ce904b6802df9e310c6053c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa7d5e8882e07947969161d2da89dab24d5e2549ea5138b95fef4bf90ffa82b2eb451133281c1de72c328a903850e6434a701d753b55e7c9aae690f5709e6b50
|
7
|
+
data.tar.gz: df6957d37df1670ad0362c333b60540ed8242b2f8b3db7a84fcf2219cdda5012a5698cbd2cad51054d8cb4a1241b208db46d406df4c8caae68016b78a2980a20
|
data/Gemfile
CHANGED
@@ -17,10 +17,8 @@ end
|
|
17
17
|
|
18
18
|
group :development, :test do
|
19
19
|
if ruby_version >= Gem::Version.new('2.4')
|
20
|
-
# No need to run byebug
|
20
|
+
# No need to run byebug on earlier versions
|
21
21
|
gem 'byebug', platform: :mri
|
22
|
-
gem 'pry', platform: :mri
|
23
|
-
gem 'pry-byebug', platform: :mri
|
24
22
|
end
|
25
23
|
|
26
24
|
if ruby_version >= Gem::Version.new('2.7')
|
data/lib/qfill/result.rb
CHANGED
@@ -28,6 +28,8 @@ module Qfill
|
|
28
28
|
:max_tracker
|
29
29
|
|
30
30
|
def self.get_limit_from_max_and_ratio(all_list_max, ratio, remain = nil)
|
31
|
+
return 1 if remain == 1
|
32
|
+
|
31
33
|
limit = (all_list_max * ratio).round(0)
|
32
34
|
# If we rounded down to zero we have to keep at least one.
|
33
35
|
# This is because with small origin sets all ratios might round down to 0.
|
@@ -144,6 +146,7 @@ module Qfill
|
|
144
146
|
self.current_count = 0
|
145
147
|
end
|
146
148
|
|
149
|
+
# Results can overfill, because fractions.
|
147
150
|
def is_full?
|
148
151
|
self.total_count >= max
|
149
152
|
end
|
@@ -80,20 +80,19 @@ module Qfill
|
|
80
80
|
def fill_up_to_ratio!
|
81
81
|
ratio = 1.0 / popper.primary.length # 1 divided by the number of queues
|
82
82
|
max_from_list = Qfill::Result.get_limit_from_max_and_ratio(result.max, ratio, remaining)
|
83
|
-
while !is_full? && !result.is_full? && !popper.totally_empty? && (origin_list = popper.current_list)
|
84
|
-
array_to_push = popper.next_objects!(origin_list.name,
|
83
|
+
while !is_full? && (take = [max_from_list, remaining].min) && (!result.is_full? || take == 1) && !popper.totally_empty? && (origin_list = popper.current_list)
|
84
|
+
array_to_push = popper.next_objects!(origin_list.name, take)
|
85
85
|
self.added = result.push(array_to_push, origin_list.name)
|
86
86
|
bump!
|
87
|
-
puts "[fill_up_to_ratio!]#{self}[Added:#{added}][Max List:#{max_from_list}][ratio:#{ratio}][
|
87
|
+
puts "[fill_up_to_ratio!]#{self}[Added:#{added}][Max List:#{max_from_list}][ratio:#{ratio}][take:#{take}]" if Qfill::VERBOSE
|
88
88
|
popper.set_next_as_current!
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
92
|
def fill_according_to_list_ratios!
|
93
|
-
# puts "#{!is_full?} && #{result.fill_count} >= #{result.max} && #{!self.popper.totally_empty?} && #{
|
94
|
-
while !is_full? && !
|
95
|
-
|
96
|
-
array_to_push = popper.next_objects!(list_ratio_tuple[0], max_from_list)
|
93
|
+
# puts "#{!is_full?} && #{result.fill_count} >= #{result.max} && #{!self.popper.totally_empty?} && #{result.current_list_ratio}"
|
94
|
+
while !is_full? && !popper.totally_empty? && (list_ratio_tuple = result.current_list_ratio) && (take = Qfill::Result.get_limit_from_max_and_ratio(result.max, list_ratio_tuple[1], remaining)) && (!result.is_full? || take == 1)
|
95
|
+
array_to_push = popper.next_objects!(list_ratio_tuple[0], take)
|
97
96
|
self.added = result.push(array_to_push, list_ratio_tuple[0])
|
98
97
|
bump!
|
99
98
|
puts "[fill_according_to_list_ratios!]#{self}[#{list_ratio_tuple[0]}][added:#{added}]" if Qfill::VERBOSE
|
data/lib/qfill/version.rb
CHANGED
data/spec/qfill/manager_spec.rb
CHANGED
@@ -731,12 +731,15 @@ describe Qfill::Manager do
|
|
731
731
|
end
|
732
732
|
|
733
733
|
context 'when strategy => :time_slice' do
|
734
|
+
let(:elements) { 2400 }
|
735
|
+
let(:window_size) { 20 }
|
736
|
+
let(:pane_size) { 2 }
|
734
737
|
let(:popper) do
|
735
738
|
Qfill::Popper.from_array_of_hashes(
|
736
739
|
[
|
737
740
|
{
|
738
741
|
name: 'data',
|
739
|
-
elements: build_elements('ef',
|
742
|
+
elements: build_elements('ef', elements)
|
740
743
|
}
|
741
744
|
]
|
742
745
|
)
|
@@ -746,23 +749,45 @@ describe Qfill::Manager do
|
|
746
749
|
popper: popper,
|
747
750
|
strategy: :time_slice,
|
748
751
|
strategy_options: {
|
749
|
-
window_size:
|
752
|
+
window_size: window_size,
|
750
753
|
window_units: 'minutes',
|
751
|
-
pane_size:
|
754
|
+
pane_size: pane_size,
|
752
755
|
pane_units: 'seconds'
|
753
756
|
}
|
754
757
|
}
|
755
758
|
end
|
756
759
|
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
+
shared_examples_for "a good citizen" do
|
761
|
+
describe '#new' do
|
762
|
+
it 'does not raise any errors' do
|
763
|
+
expect { described_class.new(arguments) }.not_to raise_error
|
764
|
+
end
|
765
|
+
end
|
766
|
+
|
767
|
+
describe '#fill!' do
|
768
|
+
it 'instantiates with pusher' do
|
769
|
+
expect { described_class.new(arguments).fill! }.not_to raise_error
|
770
|
+
end
|
760
771
|
end
|
761
772
|
end
|
762
773
|
|
763
|
-
|
764
|
-
|
765
|
-
|
774
|
+
it_behaves_like "a good citizen"
|
775
|
+
|
776
|
+
context "other options" do
|
777
|
+
let(:elements) { 101 }
|
778
|
+
|
779
|
+
context "5 minutes by 3 seconds" do
|
780
|
+
let(:window_size) { 5 }
|
781
|
+
let(:pane_size) { 3 }
|
782
|
+
|
783
|
+
it_behaves_like "a good citizen"
|
784
|
+
end
|
785
|
+
|
786
|
+
context "7 minutes by 4 seconds" do
|
787
|
+
let(:window_size) { 7 }
|
788
|
+
let(:pane_size) { 4 }
|
789
|
+
|
790
|
+
it_behaves_like "a good citizen"
|
766
791
|
end
|
767
792
|
end
|
768
793
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qfill
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Boling
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
110
|
requirements: []
|
111
|
-
rubygems_version: 3.2.
|
111
|
+
rubygems_version: 3.2.29
|
112
112
|
signing_key:
|
113
113
|
specification_version: 4
|
114
114
|
summary: 'You have a set of arrays that need to be turned into a different set of
|