From 7e188a3d36b9c53867822a9f59caa7739953b690 Mon Sep 17 00:00:00 2001 From: olegphenomenon Date: Wed, 24 Nov 2021 09:21:46 +0200 Subject: [PATCH] added profile pghero --- Gemfile | 4 + Gemfile.lock | 10 ++- config/routes.rb | 6 ++ ...0211124071418_create_pghero_query_stats.rb | 15 ++++ db/structure.sql | 86 ++++++++++++++++--- 5 files changed, 108 insertions(+), 13 deletions(-) create mode 100644 db/migrate/20211124071418_create_pghero_query_stats.rb diff --git a/Gemfile b/Gemfile index 5f18921ae..1900c02f1 100644 --- a/Gemfile +++ b/Gemfile @@ -98,3 +98,7 @@ group :test do end gem 'aws-sdk-sesv2', '~> 1.19' + +# profiles +gem 'pghero' +gem 'pg_query', '>= 0.9.0' diff --git a/Gemfile.lock b/Gemfile.lock index d7e236218..03e789767 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -233,6 +233,8 @@ GEM thor (>= 0.14.0, < 2) globalid (0.5.2) activesupport (>= 5.0) + google-protobuf (3.19.1) + google-protobuf (3.19.1-x86_64-linux) gyoku (1.3.1) builder (>= 2.1.2) haml (5.2.2) @@ -338,6 +340,10 @@ GEM request_store (~> 1.1) pdfkit (0.8.5) pg (1.2.3) + pg_query (2.1.2) + google-protobuf (>= 3.17.1) + pghero (2.8.1) + activerecord (>= 5) pry (0.14.1) coderay (~> 1.1) method_source (~> 1.0) @@ -555,6 +561,8 @@ DEPENDENCIES paper_trail (~> 12.1) pdfkit pg (= 1.2.3) + pg_query (>= 0.9.0) + pghero pry (= 0.14.1) puma que @@ -579,4 +587,4 @@ DEPENDENCIES wkhtmltopdf-binary (~> 0.12.5.1) BUNDLED WITH - 2.2.27 + 2.2.31 diff --git a/config/routes.rb b/config/routes.rb index 4772fbe4b..66debd4b4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -5,6 +5,12 @@ Rails.application.routes.draw do get 'practice/index' get 'practice/contact' # https://github.com/internetee/epp_proxy#translation-of-epp-calls + # + # profiles + if Rails.env.development? || Rails.env.staging? + mount PgHero::Engine, at: "pghero" + end + namespace :epp do constraints(EppConstraint.new(:session)) do get 'session/hello', to: 'sessions#hello', as: 'hello' diff --git a/db/migrate/20211124071418_create_pghero_query_stats.rb b/db/migrate/20211124071418_create_pghero_query_stats.rb new file mode 100644 index 000000000..4348f2de7 --- /dev/null +++ b/db/migrate/20211124071418_create_pghero_query_stats.rb @@ -0,0 +1,15 @@ +class CreatePgheroQueryStats < ActiveRecord::Migration[6.1] + def change + create_table :pghero_query_stats do |t| + t.text :database + t.text :user + t.text :query + t.integer :query_hash, limit: 8 + t.float :total_time + t.integer :calls, limit: 8 + t.timestamp :captured_at + end + + add_index :pghero_query_stats, [:database, :captured_at] + end +end diff --git a/db/structure.sql b/db/structure.sql index d718d0d33..04fee1b31 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -71,7 +71,8 @@ COMMENT ON EXTENSION pgcrypto IS 'cryptographic functions'; CREATE TYPE public.validation_type AS ENUM ( 'email_validation', - 'manual_force_delete' + 'manual_force_delete', + 'nameserver_validation' ); @@ -2260,6 +2261,41 @@ CREATE SEQUENCE public.payment_orders_id_seq ALTER SEQUENCE public.payment_orders_id_seq OWNED BY public.payment_orders.id; +-- +-- Name: pghero_query_stats; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.pghero_query_stats ( + id bigint NOT NULL, + database text, + "user" text, + query text, + query_hash bigint, + total_time double precision, + calls bigint, + captured_at timestamp without time zone +); + + +-- +-- Name: pghero_query_stats_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.pghero_query_stats_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: pghero_query_stats_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.pghero_query_stats_id_seq OWNED BY public.pghero_query_stats.id; + + -- -- Name: prices; Type: TABLE; Schema: public; Owner: - -- @@ -2619,8 +2655,7 @@ CREATE TABLE public.validation_events ( validation_eventable_type character varying, validation_eventable_id bigint, created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL, - event_type public.validation_type + updated_at timestamp(6) without time zone NOT NULL ); @@ -3162,6 +3197,13 @@ ALTER TABLE ONLY public.notifications ALTER COLUMN id SET DEFAULT nextval('publi ALTER TABLE ONLY public.payment_orders ALTER COLUMN id SET DEFAULT nextval('public.payment_orders_id_seq'::regclass); +-- +-- Name: pghero_query_stats id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.pghero_query_stats ALTER COLUMN id SET DEFAULT nextval('public.pghero_query_stats_id_seq'::regclass); + + -- -- Name: prices id; Type: DEFAULT; Schema: public; Owner: - -- @@ -3685,6 +3727,14 @@ ALTER TABLE ONLY public.payment_orders ADD CONSTRAINT payment_orders_pkey PRIMARY KEY (id); +-- +-- Name: pghero_query_stats pghero_query_stats_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.pghero_query_stats + ADD CONSTRAINT pghero_query_stats_pkey PRIMARY KEY (id); + + -- -- Name: prices prices_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -4049,6 +4099,13 @@ CREATE INDEX index_domain_transfers_on_domain_id ON public.domain_transfers USIN CREATE INDEX index_domains_on_delete_date ON public.domains USING btree (delete_date); +-- +-- Name: index_domains_on_json_statuses_history; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_domains_on_json_statuses_history ON public.domains USING gin (json_statuses_history); + + -- -- Name: index_domains_on_name; Type: INDEX; Schema: public; Owner: - -- @@ -4441,6 +4498,13 @@ CREATE INDEX index_notifications_on_registrar_id ON public.notifications USING b CREATE INDEX index_payment_orders_on_invoice_id ON public.payment_orders USING btree (invoice_id); +-- +-- Name: index_pghero_query_stats_on_database_and_captured_at; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_pghero_query_stats_on_database_and_captured_at ON public.pghero_query_stats USING btree (database, captured_at); + + -- -- Name: index_prices_on_zone_id; Type: INDEX; Schema: public; Owner: - -- @@ -4490,13 +4554,6 @@ CREATE INDEX index_users_on_identity_code ON public.users USING btree (identity_ CREATE INDEX index_users_on_registrar_id ON public.users USING btree (registrar_id); --- --- Name: index_validation_events_on_event_type; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_validation_events_on_event_type ON public.validation_events USING btree (event_type); - - -- -- Name: index_validation_events_on_validation_eventable; Type: INDEX; Schema: public; Owner: - -- @@ -5232,7 +5289,12 @@ INSERT INTO "schema_migrations" (version) VALUES ('20210215101019'), ('20210616112332'), ('20210629074044'), -('20210628090353'), ('20210708131814'), ('20210729131100'), -('20210729134625'); +('20210729134625'), +('20211028122103'), +('20211028125245'), +('20211029082225'), +('20211124071418'); + +