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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87731151937f4cd67118f193d514e5f91dff0f1d4e2c10b6420fa65a35534393
4
- data.tar.gz: 2057a99edf427f0266194a57f5b53cc2207173830eddbe5aff9914056bb43e4b
3
+ metadata.gz: 842129af572462687c6aa5949d2883a31735dac45888d742176eddbc21af7428
4
+ data.tar.gz: c29f00a632cf79db2a73577b2e88cfa326eff090370da85af0e95b71c137acee
5
5
  SHA512:
6
- metadata.gz: db718e660550a3f38b5dee9ffd990a5255112f78e1bc5c03850e12738c8946b59177c5d2d03e1b751880e2d3a8ba1fd1148244355a1823f6c2b2cd98367325a0
7
- data.tar.gz: f1fe04612f3adf8d9f6351f3dee6fce280a70586b4976936c8e282fa19cbdacb9b05b6cddc920bedbb5efb9b097659ccdc52e788d998135ce190af6a20702596
6
+ metadata.gz: b950e9dbd1551ad923eb6cdf6c21dcbd9b5e4b6b8728fde25e7daa46f302566ef9f17332cb76de7597f0665b1a8f952ddb92beece88f63c247ee7ac51dbbb809
7
+ data.tar.gz: 666f952f29cf6ffccb5806cad45bc8fb53ae1f673eaaf615bdd587d6295e06d9ee193ace3dc3747476d9b1d569e67825c03f6fbb0fd67d7c9e9fc099eb3ea5b5
data/.gitignore CHANGED
@@ -5,3 +5,4 @@ Gemfile.lock
5
5
  /coverage
6
6
  .DS_Store
7
7
  .idea
8
+ *.iml
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-client.
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
 
@@ -1,9 +1,9 @@
1
1
  # To publish the next version:
2
2
  # gem build intermix-client.gemspec
3
- # gem push intermix-client-0.0.1.gem
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.2'
6
+ spec.version = '0.0.3'
7
7
  spec.authors = ['Joe Manley']
8
8
  spec.email = ['joemanley201@gmail.com']
9
9
 
@@ -1,8 +1,8 @@
1
1
  module Intermix
2
2
  class Vacuum
3
- DEFAULT_STATS_OFF_THRESHOLD = 0.10
4
- DEFAULT_UNSORTED_THRESHOLD = 0.10
5
- DEFAULT_VACUUM_THRESHOLD = 0.95
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
- :stats_off_threshold, :unsorted_threshold,
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
- stats_off_threshold: DEFAULT_STATS_OFF_THRESHOLD, unsorted_threshold: DEFAULT_UNSORTED_THRESHOLD,
21
- vacuum_threshold: DEFAULT_VACUUM_THRESHOLD,
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
- @stats_off_threshold = stats_off_threshold
34
- @unsorted_threshold = unsorted_threshold
35
- @vacuum_threshold_pct = [vacuum_threshold * 100, 100].min
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 <= @stats_off_threshold
51
+ elsif table.stats_pct_off <= @stats_off_threshold_pct
51
52
  false
52
- elsif table.size_pct_unsorted <= @unsorted_threshold
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.to_i} percent;\n"
115
+ "VACUUM #{command} #{table.full_name} to #{@vacuum_threshold_pct} percent;\n"
115
116
  end
116
117
 
117
118
  def analyze_command(table:)
@@ -14,8 +14,8 @@ RSpec.shared_context 'stubbed_client' do
14
14
  schema_name: 'public',
15
15
  table_id: 1,
16
16
  table_name: 'events',
17
- stats_pct_off: 0.12,
18
- size_pct_unsorted: 0.13,
17
+ stats_pct_off: 12,
18
+ size_pct_unsorted: 13,
19
19
  row_count: 123_456,
20
20
  sort_key: 'id'
21
21
  }
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(0.12)
25
- expect(subject.size_pct_unsorted).to eq(0.13)
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.stats_off_threshold).to eq(0.10)
63
- expect(subject.stats_off_threshold).to eq(0.10)
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(:stats_off_threshold) { 0.21 }
75
- let(:unsorted_threshold) { 0.22 }
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: 0.45, size_pct_unsorted: 0.41), # included
79
- stubbed_table.merge(table_name: 'table2', stats_pct_off: 0.56, size_pct_unsorted: 0.78) # included
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: 0.45, size_pct_unsorted: nil), # excluded
85
- stubbed_table.merge(table_name: 'table4', stats_pct_off: 0.45, size_pct_unsorted: 0.20), # excluded
86
- stubbed_table.merge(table_name: 'table5', stats_pct_off: 0.20, size_pct_unsorted: 0.41) # excluded
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
- stats_off_threshold: stats_off_threshold, unsorted_threshold: unsorted_threshold,
103
- vacuum_threshold: 0.99)
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.2
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-08 00:00:00.000000000 Z
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