intermix-client 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Changelog.md +8 -0
- data/README.md +1 -1
- data/intermix-client.gemspec +2 -2
- data/lib/intermix/vacuum.rb +13 -12
- data/spec/support/shared_contexts/stubbed_client.rb +2 -2
- data/spec/table_spec.rb +2 -2
- data/spec/vacuum_spec.rb +12 -11
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 842129af572462687c6aa5949d2883a31735dac45888d742176eddbc21af7428
|
4
|
+
data.tar.gz: c29f00a632cf79db2a73577b2e88cfa326eff090370da85af0e95b71c137acee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b950e9dbd1551ad923eb6cdf6c21dcbd9b5e4b6b8728fde25e7daa46f302566ef9f17332cb76de7597f0665b1a8f952ddb92beece88f63c247ee7ac51dbbb809
|
7
|
+
data.tar.gz: 666f952f29cf6ffccb5806cad45bc8fb53ae1f673eaaf615bdd587d6295e06d9ee193ace3dc3747476d9b1d569e67825c03f6fbb0fd67d7c9e9fc099eb3ea5b5
|
data/.gitignore
CHANGED
data/Changelog.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
## 0.0.3
|
2
|
+
* [Intermix::Vacuum - fix thresholds to actually respect percent values](https://github.com/tophatter/intermix-api-ruby/pull/9)
|
3
|
+
|
4
|
+
## 0.0.2
|
5
|
+
* [Downgrade httparty from 0.17.0 to 0.14.0](https://github.com/tophatter/intermix-api-ruby/pull/6)
|
6
|
+
|
7
|
+
## 0.0.1
|
8
|
+
* [Basic client implementation for generating the vacuum script](https://github.com/tophatter/intermix-api-ruby/pull/4)
|
data/README.md
CHANGED
@@ -54,7 +54,7 @@ After checking out the repo, run `bundle install` to install dependencies. Then,
|
|
54
54
|
|
55
55
|
## Contributing
|
56
56
|
|
57
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/tophatter/intermix-
|
57
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/tophatter/intermix-api-ruby.git.
|
58
58
|
|
59
59
|
## License
|
60
60
|
|
data/intermix-client.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# To publish the next version:
|
2
2
|
# gem build intermix-client.gemspec
|
3
|
-
# gem push intermix-client-
|
3
|
+
# gem push intermix-client-{VERSION}.gem
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = 'intermix-client'
|
6
|
-
spec.version = '0.0.
|
6
|
+
spec.version = '0.0.3'
|
7
7
|
spec.authors = ['Joe Manley']
|
8
8
|
spec.email = ['joemanley201@gmail.com']
|
9
9
|
|
data/lib/intermix/vacuum.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Intermix
|
2
2
|
class Vacuum
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
DEFAULT_STATS_OFF_THRESHOLD_PCT = 10
|
4
|
+
DEFAULT_UNSORTED_THRESHOLD_PCT = 10
|
5
|
+
DEFAULT_VACUUM_THRESHOLD_PCT = 95
|
6
6
|
|
7
7
|
REDSHIFT_USERNAME = ''
|
8
8
|
REDSHIFT_HOST = ''
|
@@ -12,13 +12,14 @@ module Intermix
|
|
12
12
|
|
13
13
|
attr_reader :client,
|
14
14
|
:full, :delete_only, :sort, :analyze,
|
15
|
-
:
|
15
|
+
:stats_off_threshold_pct, :unsorted_threshold_pct,
|
16
|
+
:vacuum_threshold_pct,
|
16
17
|
:admin_user, :host, :port
|
17
18
|
|
18
19
|
def initialize(client:,
|
19
20
|
delete_only: false, full: false, sort: false,
|
20
|
-
|
21
|
-
|
21
|
+
stats_off_threshold_pct: DEFAULT_STATS_OFF_THRESHOLD_PCT, unsorted_threshold_pct: DEFAULT_UNSORTED_THRESHOLD_PCT,
|
22
|
+
vacuum_threshold_pct: DEFAULT_VACUUM_THRESHOLD_PCT,
|
22
23
|
admin_user: REDSHIFT_USERNAME, host: REDSHIFT_HOST, port: REDSHIFT_PORT)
|
23
24
|
raise ArgumentError, 'client cannot be nil.' unless client.present?
|
24
25
|
raise ArgumentError, 'invalid vacuum mode.' if full && [delete_only, sort].any?
|
@@ -30,9 +31,9 @@ module Intermix
|
|
30
31
|
@sort = sort
|
31
32
|
@analyze = true if full || delete_only
|
32
33
|
|
33
|
-
@
|
34
|
-
@
|
35
|
-
@vacuum_threshold_pct
|
34
|
+
@stats_off_threshold_pct = stats_off_threshold_pct
|
35
|
+
@unsorted_threshold_pct = unsorted_threshold_pct
|
36
|
+
@vacuum_threshold_pct = [vacuum_threshold_pct, 100].min
|
36
37
|
|
37
38
|
@admin_user = admin_user
|
38
39
|
@host = host
|
@@ -47,9 +48,9 @@ module Intermix
|
|
47
48
|
false
|
48
49
|
elsif table.size_pct_unsorted.nil?
|
49
50
|
false
|
50
|
-
elsif table.stats_pct_off <= @
|
51
|
+
elsif table.stats_pct_off <= @stats_off_threshold_pct
|
51
52
|
false
|
52
|
-
elsif table.size_pct_unsorted <= @
|
53
|
+
elsif table.size_pct_unsorted <= @unsorted_threshold_pct
|
53
54
|
false
|
54
55
|
else
|
55
56
|
true
|
@@ -111,7 +112,7 @@ module Intermix
|
|
111
112
|
table.sort_key == 'INTERLEAVED' ? 'REINDEX' : 'SORT ONLY'
|
112
113
|
end
|
113
114
|
|
114
|
-
"VACUUM #{command} #{table.full_name} to #{@vacuum_threshold_pct
|
115
|
+
"VACUUM #{command} #{table.full_name} to #{@vacuum_threshold_pct} percent;\n"
|
115
116
|
end
|
116
117
|
|
117
118
|
def analyze_command(table:)
|
data/spec/table_spec.rb
CHANGED
@@ -21,8 +21,8 @@ RSpec.describe Intermix::Table do
|
|
21
21
|
expect(subject.schema_name).to eq('public')
|
22
22
|
expect(subject.table_id).to eq(1)
|
23
23
|
expect(subject.table_name).to eq('events')
|
24
|
-
expect(subject.stats_pct_off).to eq(
|
25
|
-
expect(subject.size_pct_unsorted).to eq(
|
24
|
+
expect(subject.stats_pct_off).to eq(12)
|
25
|
+
expect(subject.size_pct_unsorted).to eq(13)
|
26
26
|
expect(subject.row_count).to eq(123_456)
|
27
27
|
expect(subject.sort_key).to eq('id')
|
28
28
|
end
|
data/spec/vacuum_spec.rb
CHANGED
@@ -59,8 +59,9 @@ RSpec.describe Intermix::Vacuum do
|
|
59
59
|
expect(subject.sort).to be_falsey
|
60
60
|
expect(subject.analyze).to be_truthy
|
61
61
|
|
62
|
-
expect(subject.
|
63
|
-
expect(subject.
|
62
|
+
expect(subject.stats_off_threshold_pct).to eq(10)
|
63
|
+
expect(subject.unsorted_threshold_pct).to eq(10)
|
64
|
+
expect(subject.vacuum_threshold_pct).to eq(95)
|
64
65
|
|
65
66
|
expect(subject.admin_user).to eq('')
|
66
67
|
expect(subject.host).to eq('')
|
@@ -71,19 +72,19 @@ RSpec.describe Intermix::Vacuum do
|
|
71
72
|
end
|
72
73
|
|
73
74
|
describe '#generate_script', :stubbed_client do
|
74
|
-
let(:
|
75
|
-
let(:
|
75
|
+
let(:stats_off_threshold_pct) { 21 }
|
76
|
+
let(:unsorted_threshold_pct) { 22 }
|
76
77
|
let(:threshold_met) do
|
77
78
|
[
|
78
|
-
stubbed_table.merge(table_name: 'table1', stats_pct_off:
|
79
|
-
stubbed_table.merge(table_name: 'table2', stats_pct_off:
|
79
|
+
stubbed_table.merge(table_name: 'table1', stats_pct_off: 45, size_pct_unsorted: 41), # included
|
80
|
+
stubbed_table.merge(table_name: 'table2', stats_pct_off: 56, size_pct_unsorted: 78) # included
|
80
81
|
]
|
81
82
|
end
|
82
83
|
let(:threshold_unmet) do
|
83
84
|
[
|
84
|
-
stubbed_table.merge(table_name: 'table3', stats_pct_off:
|
85
|
-
stubbed_table.merge(table_name: 'table4', stats_pct_off:
|
86
|
-
stubbed_table.merge(table_name: 'table5', stats_pct_off:
|
85
|
+
stubbed_table.merge(table_name: 'table3', stats_pct_off: 45, size_pct_unsorted: nil), # excluded
|
86
|
+
stubbed_table.merge(table_name: 'table4', stats_pct_off: 45, size_pct_unsorted: 20), # excluded
|
87
|
+
stubbed_table.merge(table_name: 'table5', stats_pct_off: 20, size_pct_unsorted: 41) # excluded
|
87
88
|
]
|
88
89
|
end
|
89
90
|
let(:excluded_schema) do
|
@@ -99,8 +100,8 @@ RSpec.describe Intermix::Vacuum do
|
|
99
100
|
subject do
|
100
101
|
vacuum = Intermix::Vacuum.new(client: stubbed_client,
|
101
102
|
delete_only: delete_only, full: full, sort: sort,
|
102
|
-
|
103
|
-
|
103
|
+
stats_off_threshold_pct: stats_off_threshold_pct, unsorted_threshold_pct: unsorted_threshold_pct,
|
104
|
+
vacuum_threshold_pct: 99)
|
104
105
|
vacuum.generate_script
|
105
106
|
end
|
106
107
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: intermix-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Manley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- ".rspec"
|
51
51
|
- ".rubocop.yml"
|
52
52
|
- ".travis.yml"
|
53
|
+
- Changelog.md
|
53
54
|
- Gemfile
|
54
55
|
- LICENSE.txt
|
55
56
|
- README.md
|