pgbouncerhero 0.1.1 → 1.0.0

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
  SHA1:
3
- metadata.gz: 827a3a4bfea83fcb9b95692c6401847a453a59e2
4
- data.tar.gz: 803feac4e01686ff104e1a55cd2c176d5d366907
3
+ metadata.gz: e99b6949ad102047e0cbef15d498da34637d2fd5
4
+ data.tar.gz: c6e4afdfbdec05be13c7f1a19212458ebf3d9f31
5
5
  SHA512:
6
- metadata.gz: 9d47db11b462287b0b5ba8c9f4c42c1b4bf3cd04d46b2c0d28cff8cae6b28d4546667bc10f83d2de9193cd14c11ec976a661da53da8955d3fb620b7e0dfc42ab
7
- data.tar.gz: a096b7a22b57c9682af5a4ed4523618a616165409c6cd3416987e8dd94626c504378b7baeed0485f53be97b3fc56c939d95b88fc22679f3fcb74b191bb614f68
6
+ metadata.gz: d8226446112e91797a812d689d80fa10c4dbb83c54e36d7229d97cd7401de49c2f9894bf88f68c16d2fa8eef298f6060b16296356919f9058c26bea6782c60a9
7
+ data.tar.gz: ba8b50b569a64fbb6b58be2ba80239c341b064f18f56f82a67b0d9b0ff2edf4e4bd984a130915d8bcbc4af1f02b35d3ab79e7ab938d885add176d052c18b8ab3
@@ -1,3 +1,8 @@
1
+ ## 1.0.0
2
+
3
+ - Lazy connection for index
4
+ - Bug fixes
5
+
1
6
  ## 0.1.0
2
7
 
3
8
  - First major release
@@ -1,3 +1,5 @@
1
+ $("#segment_status_#{@database.group.name.parameterize}_#{@database.name.parameterize}").html("#{j(@database.connection ? "Online" : "Offline")}")
2
+ $("#segment_status_#{@database.group.name.parameterize}_#{@database.name.parameterize}").removeClass("grey negative positive").addClass("#{j(@database.connection ? "positive" : "negative")}")
1
3
  $("#segment_content_#{@database.group.name.parameterize}_#{@database.name.parameterize}").replaceWith("#{j(render partial: 'pg_bouncer_hero/home/card_content', locals: {database: @database, id: "segment_content_#{@database.group.name.parameterize}_#{@database.name.parameterize}"})}")
2
4
  $("#segment_refreshed_#{@database.group.name.parameterize}_#{@database.name.parameterize}").css('display', '')
3
5
  $("#segment_content_#{@database.group.name.parameterize}_#{@database.name.parameterize} .ui.progress").each(function(idx, el) { $(el).progress({ text: {active: '{value} of {total} connections'}, autoSuccess: false }); });
@@ -1,4 +1,3 @@
1
- - connected = database.connection
2
1
  .eight.wide.column{id: "segment_href_#{database.group.name.parameterize}_#{database.name.parameterize}", data: {href: summary_path(group: database.group.name.parameterize, database: database.name.parameterize)}}
3
2
  = link_to databases_path(group: database.group.name.parameterize, database: database.name.parameterize), style: 'text-decoration: none !important; color: inherit !important' do
4
3
  .ui.segments{style: 'margin-bottom: 10px;'}
@@ -6,10 +5,9 @@
6
5
  %div{style: 'float: left;'}
7
6
  %div{style: 'font-size: 16px; font-weight: bold;'}= database.name
8
7
  %div{style: 'font-size: 12px; color: grey'}= database.host
9
- %button.ui.button.basic.button{style: 'float: right;', class: connected ? 'positive': 'negative'}= connected ? 'Online' : 'Offline'
10
- - if connected
11
- = render partial: partial, locals: {database: database, id: "segment_content_#{database.group.name.parameterize}_#{database.name.parameterize}"}
12
- .ui.segment{id: "segment_refreshed_#{database.group.name.parameterize}_#{database.name.parameterize}", style: 'height: 35px; display: none;'}
13
- %span.right.floated{id: "segment_refreshed_span_#{database.group.name.parameterize}_#{database.name.parameterize}", style: 'float:right; margin-top: -6px; color: grey'}
14
- Last refresh:
15
- = Time.now.strftime("%H:%M:%S GMT%z (%Z)") # Same as new Date().toTimeString() in JS
8
+ %button.ui.button.basic.button{id: "segment_status_#{database.group.name.parameterize}_#{database.name.parameterize}", style: 'float: right;', class: 'grey'}= 'N/A'
9
+ = render partial: partial, locals: {database: database, id: "segment_content_#{database.group.name.parameterize}_#{database.name.parameterize}"}
10
+ .ui.segment{id: "segment_refreshed_#{database.group.name.parameterize}_#{database.name.parameterize}", style: 'height: 35px; display: none;'}
11
+ %span.right.floated{id: "segment_refreshed_span_#{database.group.name.parameterize}_#{database.name.parameterize}", style: 'float:right; margin-top: -6px; color: grey'}
12
+ Last refresh:
13
+ = Time.now.strftime("%H:%M:%S GMT%z (%Z)") # Same as new Date().toTimeString() in JS
@@ -1,26 +1,28 @@
1
- .ui.horizontal.segments{id: id, style: 'background-color: white !important;'}
2
- .ui.segment
3
- - summary = database.summary
4
- %div
5
- %i.users.icon
6
- - number = summary.select { |row| row['list'] == 'users' }.first['items']
7
- = pluralize(number, 'user')
8
- %div
9
- %i.database.icon
10
- - number = summary.select { |row| row['list'] == 'databases' }.first['items'].to_i - 1 # Removed pgbouncer
11
- = pluralize(number, 'database')
12
- %div
13
- %i.plug.icon
14
- - number = summary.select { |row| row['list'] == 'pools' }.first['items'].to_i - 1 # Removed pgbouncer
15
- = pluralize(number, 'pool')
16
- .ui.segment
17
- %ul{style: 'margin: 0; padding-left: 5px;'}
18
- - summary.select{ |row| row.key?(:databases_details) }.first[:databases_details].each do |db|
19
- %li{style: 'margin: 0; list-style-type: none;'}
20
- %span
21
- %i.database.icon
22
- %strong=db['name']
23
- .ui.progress.small.success{data:{value: db['current_connections'], total: db['max_connections']}, style: 'float:right; width: 150px; margin-top:4px;'}
24
- .bar
25
- .progress
26
- .label Connections
1
+ - connected = database.connection
2
+ - if connected
3
+ .ui.horizontal.segments{id: id, style: 'background-color: white !important;'}
4
+ .ui.segment
5
+ - summary = database.summary
6
+ %div
7
+ %i.users.icon
8
+ - number = summary.select { |row| row['list'] == 'users' }.first['items']
9
+ = pluralize(number, 'user')
10
+ %div
11
+ %i.database.icon
12
+ - number = summary.select { |row| row['list'] == 'databases' }.first['items'].to_i - 1 # Removed pgbouncer
13
+ = pluralize(number, 'database')
14
+ %div
15
+ %i.plug.icon
16
+ - number = summary.select { |row| row['list'] == 'pools' }.first['items'].to_i - 1 # Removed pgbouncer
17
+ = pluralize(number, 'pool')
18
+ .ui.segment
19
+ %ul{style: 'margin: 0; padding-left: 5px;'}
20
+ - summary.select{ |row| row.key?(:databases_details) }.first[:databases_details].each do |db|
21
+ %li{style: 'margin: 0; list-style-type: none;'}
22
+ %span
23
+ %i.database.icon
24
+ %strong=db['name']
25
+ .ui.progress.small.success{data:{value: db['current_connections'], total: db['max_connections']}, style: 'float:right; width: 150px; margin-top:4px;'}
26
+ .bar
27
+ .progress
28
+ .label Connections
@@ -7,7 +7,7 @@
7
7
  .sixteen.wide.row
8
8
  .sixteen.wide.column
9
9
  %h3.ui.dividing.header{style: 'margin-bottom: 10px;'}= group.name
10
- = render partial: "card", collection: group.databases, as: :database, locals: {partial: 'card_loading_content'}
10
+ = render partial: "card", collection: group.databases, as: :database, locals: {partial: 'card_loading_content', lazy: true}
11
11
 
12
12
  :javascript
13
13
  document.addEventListener("DOMContentLoaded", function(event) {
@@ -22,10 +22,13 @@
22
22
  var id = el.attr('id');
23
23
  var href = el.data('href');
24
24
  var refreshed_id = id.replace('href', 'refreshed_span');
25
- document.getElementById(refreshed_id).innerHTML = 'Refreshing...';
26
- $.get(href, function(data) {
27
- document.getElementById(refreshed_id).innerHTML = 'Last refresh: ' + new Date().toTimeString();
28
- });
25
+ var refreshed_div = document.getElementById(refreshed_id);
26
+ if (refreshed_div) {
27
+ refreshed_div.innerHTML = 'Refreshing...';
28
+ $.get(href, function(data) {
29
+ refreshed_div.innerHTML = 'Last refresh: ' + new Date().toTimeString();
30
+ });
31
+ }
29
32
  });
30
33
  }, 60 * 1000)
31
34
  });
@@ -7,6 +7,7 @@ module PgBouncerHero
7
7
  @user = user
8
8
  @password = password
9
9
  @dbname = dbname
10
+ @timeout = ENV["PGBOUNCERHERO_TIMEOUT"] || 5
10
11
  end
11
12
 
12
13
  def connection
@@ -18,10 +19,10 @@ module PgBouncerHero
18
19
  user: @user,
19
20
  password: @password,
20
21
  dbname: @dbname,
21
- connect_timeout: 5
22
+ connect_timeout: @timeout
22
23
  )
23
- rescue => e
24
- Rails.logger.info(e)
24
+ rescue Exception => e
25
+ Rails.logger.error("[PGBouncerHero] Host:#{@host} | Database Name:#{@dbname} | Timeout: #{@timeout}s => #{e}")
25
26
  nil
26
27
  end
27
28
  end
@@ -2,12 +2,14 @@ module PgBouncerHero
2
2
  module Methods
3
3
  module Basics
4
4
  def summary
5
- l = lists
6
- d = databases
7
- l = l.as_json
8
- d = d.as_json.reject { |a| a['name'] == 'pgbouncer' }
9
- l.push({databases_details: d})
10
- l
5
+ if connection
6
+ l = lists
7
+ d = databases
8
+ l = l.as_json
9
+ d = d.as_json.reject { |a| a['name'] == 'pgbouncer' }
10
+ l.push({databases_details: d})
11
+ l
12
+ end
11
13
  end
12
14
  def databases
13
15
  connection.exec("SHOW databases")
@@ -1,3 +1,3 @@
1
1
  module PgBouncerHero
2
- VERSION = "0.1.1"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pgbouncerhero
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Quentin Rousseau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-15 00:00:00.000000000 Z
11
+ date: 2018-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  version: '0'
182
182
  requirements: []
183
183
  rubyforge_project:
184
- rubygems_version: 2.5.2
184
+ rubygems_version: 2.5.2.2
185
185
  signing_key:
186
186
  specification_version: 4
187
187
  summary: A graphical user interface for your PGBouncers