diff options
-rw-r--r-- | Gemfile | 6 | ||||
-rw-r--r-- | Gemfile.lock | 18 | ||||
-rw-r--r-- | app/javascript/core/settings.js | 2 | ||||
-rw-r--r-- | app/workers/scheduler/pghero_scheduler.rb | 11 | ||||
-rw-r--r-- | config/sidekiq.yml | 3 | ||||
-rw-r--r-- | db/migrate/20181007025445_create_pghero_space_stats.rb | 13 | ||||
-rw-r--r-- | db/schema.rb | 11 |
7 files changed, 50 insertions, 14 deletions
diff --git a/Gemfile b/Gemfile index d77a29b79..7474efb3a 100644 --- a/Gemfile +++ b/Gemfile @@ -13,7 +13,7 @@ gem 'hamlit-rails', '~> 0.2' gem 'pg', '~> 1.1' gem 'makara', '~> 0.4' gem 'pghero', '~> 2.2' -gem 'dotenv-rails', '~> 2.2', '< 2.3' +gem 'dotenv-rails', '~> 2.5' gem 'aws-sdk-s3', '~> 1.21', require: false gem 'fog-core', '~> 2.1' @@ -109,7 +109,7 @@ end group :test do gem 'capybara', '~> 3.9' gem 'climate_control', '~> 0.2' - gem 'faker', '~> 1.8' + gem 'faker', '~> 1.9' gem 'microformats', '~> 4.0' gem 'rails-controller-testing', '~> 1.0' gem 'rspec-sidekiq', '~> 3.0' @@ -133,7 +133,7 @@ group :development do gem 'scss_lint', '~> 0.57', require: false gem 'capistrano', '~> 3.11' - gem 'capistrano-rails', '~> 1.3' + gem 'capistrano-rails', '~> 1.4' gem 'capistrano-rbenv', '~> 2.1' gem 'capistrano-yarn', '~> 2.0' diff --git a/Gemfile.lock b/Gemfile.lock index 3583bc396..0b1a2c579 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -118,7 +118,7 @@ GEM capistrano-bundler (1.3.0) capistrano (~> 3.1) sshkit (~> 1.2) - capistrano-rails (1.3.1) + capistrano-rails (1.4.0) capistrano (~> 3.1) capistrano-bundler (~> 1.1) capistrano-rbenv (2.1.4) @@ -184,9 +184,9 @@ GEM unf (>= 0.0.5, < 1.0.0) doorkeeper (5.0.0) railties (>= 4.2) - dotenv (2.2.2) - dotenv-rails (2.2.2) - dotenv (= 2.2.2) + dotenv (2.5.0) + dotenv-rails (2.5.0) + dotenv (= 2.5.0) railties (>= 3.2, < 6.0) elasticsearch (6.0.2) elasticsearch-api (= 6.0.2) @@ -204,7 +204,7 @@ GEM tzinfo excon (0.62.0) fabrication (2.20.1) - faker (1.8.7) + faker (1.9.1) i18n (>= 0.7) faraday (0.15.0) multipart-post (>= 1.2, < 3) @@ -330,7 +330,7 @@ GEM mimemagic (~> 0.3.2) mario-redis-lock (1.2.1) redis (>= 3.0.5) - memory_profiler (0.9.11) + memory_profiler (0.9.12) method_source (0.9.0) microformats (4.0.7) json @@ -662,7 +662,7 @@ DEPENDENCIES bullet (~> 5.7) bundler-audit (~> 0.6) capistrano (~> 3.11) - capistrano-rails (~> 1.3) + capistrano-rails (~> 1.4) capistrano-rbenv (~> 2.1) capistrano-yarn (~> 2.0) capybara (~> 3.9) @@ -675,9 +675,9 @@ DEPENDENCIES devise-two-factor (~> 3.0) devise_pam_authenticatable2 (~> 9.2) doorkeeper (~> 5.0) - dotenv-rails (~> 2.2, < 2.3) + dotenv-rails (~> 2.5) fabrication (~> 2.20) - faker (~> 1.8) + faker (~> 1.9) fast_blank (~> 1.0) fastimage fog-core (~> 2.1) diff --git a/app/javascript/core/settings.js b/app/javascript/core/settings.js index 377c899dc..af97c84f9 100644 --- a/app/javascript/core/settings.js +++ b/app/javascript/core/settings.js @@ -56,7 +56,7 @@ delegate(document, '.input-copy input', 'click', ({ target }) => { }); delegate(document, '.input-copy button', 'click', ({ target }) => { - const input = target.parentNode.querySelector('input'); + const input = target.parentNode.querySelector('.input-copy__wrapper input'); input.focus(); input.select(); diff --git a/app/workers/scheduler/pghero_scheduler.rb b/app/workers/scheduler/pghero_scheduler.rb new file mode 100644 index 000000000..4453bf2cd --- /dev/null +++ b/app/workers/scheduler/pghero_scheduler.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class Scheduler::PgheroScheduler + include Sidekiq::Worker + + sidekiq_options unique: :until_executed, retry: 0 + + def perform + PgHero.capture_space_stats + end +end diff --git a/config/sidekiq.yml b/config/sidekiq.yml index 6a09bb6e9..c44af5b6c 100644 --- a/config/sidekiq.yml +++ b/config/sidekiq.yml @@ -33,3 +33,6 @@ backup_cleanup_scheduler: cron: '<%= Random.rand(0..59) %> <%= Random.rand(3..5) %> * * *' class: Scheduler::BackupCleanupScheduler + pghero_scheduler: + cron: '0 0 * * *' + class: Scheduler::PgheroScheduler diff --git a/db/migrate/20181007025445_create_pghero_space_stats.rb b/db/migrate/20181007025445_create_pghero_space_stats.rb new file mode 100644 index 000000000..6198a6f84 --- /dev/null +++ b/db/migrate/20181007025445_create_pghero_space_stats.rb @@ -0,0 +1,13 @@ +class CreatePgheroSpaceStats < ActiveRecord::Migration[5.2] + def change + create_table :pghero_space_stats do |t| + t.text :database + t.text :schema + t.text :relation + t.integer :size, limit: 8 + t.timestamp :captured_at + end + + add_index :pghero_space_stats, [:database, :captured_at] + end +end diff --git a/db/schema.rb b/db/schema.rb index 8ab3ea3c0..f9019e8cf 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2018_09_29_222014) do +ActiveRecord::Schema.define(version: 2018_10_07_025445) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -382,6 +382,15 @@ ActiveRecord::Schema.define(version: 2018_09_29_222014) do t.index ["uid"], name: "index_oauth_applications_on_uid", unique: true end + create_table "pghero_space_stats", force: :cascade do |t| + t.text "database" + t.text "schema" + t.text "relation" + t.bigint "size" + t.datetime "captured_at" + t.index ["database", "captured_at"], name: "index_pghero_space_stats_on_database_and_captured_at" + end + create_table "preview_cards", force: :cascade do |t| t.string "url", default: "", null: false t.string "title", default: "", null: false |