From 04de5da1935a0037be767b28a2a1fab7f44ce739 Mon Sep 17 00:00:00 2001 From: dinsmol Date: Thu, 3 Feb 2022 00:33:38 +0300 Subject: [PATCH 01/20] Add condition for start force delete --- app/interactions/domains/force_delete_email/base.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/interactions/domains/force_delete_email/base.rb b/app/interactions/domains/force_delete_email/base.rb index f22244045..0c3ceb579 100644 --- a/app/interactions/domains/force_delete_email/base.rb +++ b/app/interactions/domains/force_delete_email/base.rb @@ -11,6 +11,8 @@ module Domains domains = domain_contacts.map(&:domain).flatten + Domain.where(registrant_id: registrant_ids) + return if expired_or_hold_domains_exists?(domains) + domains.each do |domain| next if domain.expired? @@ -20,6 +22,12 @@ module Domains private + def expired_or_hold_domains_exists?(domains) + domains.any? do |domain| + domain.statuses.include?(DomainStatus::SERVER_HOLD) && email.include?(domain.name) + end + end + def before_execute_force_delete(domain) if domain.force_delete_scheduled? && !domain.status_notes[DomainStatus::FORCE_DELETE].nil? added_additional_email_into_notes(domain) From f6df99237f3da1407f7fbe0c15d0a98669f1e139 Mon Sep 17 00:00:00 2001 From: Thiago Youssef Date: Tue, 8 Mar 2022 12:33:50 +0200 Subject: [PATCH 02/20] Add tests for force delete email from hold domains --- .../force_delete_email/base_test.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test/interactions/force_delete_email/base_test.rb diff --git a/test/interactions/force_delete_email/base_test.rb b/test/interactions/force_delete_email/base_test.rb new file mode 100644 index 000000000..c3f688678 --- /dev/null +++ b/test/interactions/force_delete_email/base_test.rb @@ -0,0 +1,18 @@ +require 'test_helper' + +class BaseTest < ActiveSupport::TestCase + def test_hold_domains_force_delete_email + domain = domains(:shop) + domain.update!(statuses: [DomainStatus::SERVER_HOLD]) + domain.update!(expire_time: Time.zone.now + 1.year) + + registrant = domain.registrant + registrant.update!(email: "#{registrant.email.split('@').first}@#{domain.name}") + + Domains::ForceDeleteEmail::Base.run(email: registrant.email) + + domain.reload + + assert_not domain.force_delete_scheduled? + end +end From c5855f006529456480bf1b27571d5543383b903c Mon Sep 17 00:00:00 2001 From: OlegPhenomenon <37714103+OlegPhenomenon@users.noreply.github.com> Date: Tue, 15 Mar 2022 15:47:07 +0200 Subject: [PATCH 03/20] Update .ruby-version --- .ruby-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ruby-version b/.ruby-version index 94ff29cc4..75a22a26a 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.1.1 +3.0.3 From 102fd559a0aa50e35a5914c113255b6b120981ac Mon Sep 17 00:00:00 2001 From: olegphenomenon Date: Fri, 18 Mar 2022 18:02:54 +0200 Subject: [PATCH 04/20] updated structure, resolve pending migration issue --- db/structure.sql | 160 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 144 insertions(+), 16 deletions(-) diff --git a/db/structure.sql b/db/structure.sql index 5b842d4a4..0c8420f43 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -51,6 +51,20 @@ CREATE EXTENSION IF NOT EXISTS hstore WITH SCHEMA public; COMMENT ON EXTENSION hstore IS 'data type for storing sets of (key, value) pairs'; +-- +-- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner: - +-- + +CREATE EXTENSION IF NOT EXISTS pg_stat_statements WITH SCHEMA public; + + +-- +-- Name: EXTENSION pg_stat_statements; Type: COMMENT; Schema: -; Owner: - +-- + +COMMENT ON EXTENSION pg_stat_statements IS 'track execution statistics of all SQL statements executed'; + + -- -- Name: pgcrypto; Type: EXTENSION; Schema: -; Owner: - -- @@ -202,6 +216,8 @@ CREATE FUNCTION public.generate_zonefile(i_origin character varying) RETURNS tex SET default_tablespace = ''; +SET default_with_oids = false; + -- -- Name: account_activities; Type: TABLE; Schema: public; Owner: - -- @@ -809,7 +825,9 @@ CREATE TABLE public.dnskeys ( creator_str character varying, updator_str character varying, legacy_domain_id integer, - updated_at timestamp without time zone + updated_at timestamp without time zone, + validation_datetime timestamp without time zone, + failed_validation_reason character varying ); @@ -936,6 +954,7 @@ CREATE TABLE public.domains ( pending_json jsonb, force_delete_date date, statuses character varying[], + status_notes public.hstore, statuses_before_force_delete character varying[] DEFAULT '{}'::character varying[], upid integer, up_date timestamp without time zone, @@ -943,8 +962,7 @@ CREATE TABLE public.domains ( locked_by_registrant_at timestamp without time zone, force_delete_start timestamp without time zone, force_delete_data public.hstore, - json_statuses_history jsonb, - status_notes public.hstore + json_statuses_history jsonb ); @@ -1177,6 +1195,7 @@ CREATE TABLE public.invoices ( buyer_vat_no character varying, issue_date date NOT NULL, e_invoice_sent_at timestamp without time zone, + payment_link character varying, CONSTRAINT invoices_due_date_is_not_before_issue_date CHECK ((due_date >= issue_date)) ); @@ -2263,6 +2282,74 @@ 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: pghero_space_stats; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.pghero_space_stats ( + id bigint NOT NULL, + database text, + schema text, + relation text, + size bigint, + captured_at timestamp without time zone +); + + +-- +-- Name: pghero_space_stats_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.pghero_space_stats_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: pghero_space_stats_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.pghero_space_stats_id_seq OWNED BY public.pghero_space_stats.id; + + -- -- Name: prices; Type: TABLE; Schema: public; Owner: - -- @@ -2623,8 +2710,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 ); @@ -3166,6 +3252,20 @@ 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: pghero_space_stats id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.pghero_space_stats ALTER COLUMN id SET DEFAULT nextval('public.pghero_space_stats_id_seq'::regclass); + + -- -- Name: prices id; Type: DEFAULT; Schema: public; Owner: - -- @@ -3689,6 +3789,22 @@ 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: pghero_space_stats pghero_space_stats_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.pghero_space_stats + ADD CONSTRAINT pghero_space_stats_pkey PRIMARY KEY (id); + + -- -- Name: prices prices_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -4459,6 +4575,20 @@ 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_pghero_space_stats_on_database_and_captured_at; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_pghero_space_stats_on_database_and_captured_at ON public.pghero_space_stats USING btree (database, captured_at); + + -- -- Name: index_prices_on_zone_id; Type: INDEX; Schema: public; Owner: - -- @@ -4515,13 +4645,6 @@ CREATE INDEX index_users_on_registrar_id ON public.users USING btree (registrar_ CREATE INDEX index_validation_events_on_event_data ON public.validation_events USING gin (event_data); --- --- 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: - -- @@ -5267,15 +5390,20 @@ INSERT INTO "schema_migrations" (version) VALUES ('20210708131814'), ('20210729131100'), ('20210729134625'), -('20210827185249'), -('20211029073644'), +('20211028122103'), +('20211028125245'), +('20211029082225'), ('20211124071418'), +('20211124084308'), ('20211125181033'), ('20211125184334'), ('20211126085139'), +('20211231113934'), ('20220106123143'), ('20220113201642'), -('20220113220809'); - +('20220113220809'), +('20220124105717'), +('20220216113112'), +('20220228093211'); From 3149dc06da6d07146c9731faa954e86d2734e505 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 18 Mar 2022 16:15:18 +0000 Subject: [PATCH 05/20] Update dependency ransack to ~> 2.6.0 --- Gemfile | 2 +- Gemfile.lock | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Gemfile b/Gemfile index 6fb2562b0..2e728f99f 100644 --- a/Gemfile +++ b/Gemfile @@ -19,7 +19,7 @@ gem 'figaro', '~> 1.2' gem 'paper_trail', '~> 12.1' gem 'pg', '1.3.3' # 1.8 is for Rails < 5.0 -gem 'ransack', '~> 2.5.0' +gem 'ransack', '~> 2.6.0' gem 'truemail', '~> 2.4' # validates email by regexp, mail server existence and address existence gem 'validates_email_format_of', '1.6.3' # validates email against RFC 2822 and RFC 3696 diff --git a/Gemfile.lock b/Gemfile.lock index ceb070f5a..eac8ce4f6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -258,7 +258,7 @@ GEM httpi (2.4.5) rack socksify - i18n (1.8.11) + i18n (1.10.0) concurrent-ruby (~> 1.0) i18n_data (0.13.0) isikukood (0.1.2) @@ -406,9 +406,9 @@ GEM rake (>= 0.13) thor (~> 1.0) rake (13.0.6) - ransack (2.5.0) - activerecord (>= 5.2.4) - activesupport (>= 5.2.4) + ransack (2.6.0) + activerecord (>= 6.0.4) + activesupport (>= 6.0.4) i18n rbtree3 (0.6.0) redis (4.6.0) @@ -524,7 +524,7 @@ GEM wkhtmltopdf-binary (0.12.5.4) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.5.2) + zeitwerk (2.5.4) PLATFORMS ruby @@ -582,7 +582,7 @@ DEPENDENCIES que que-web rails (~> 6.1.4) - ransack (~> 2.5.0) + ransack (~> 2.6.0) rest-client rexml sass-rails From 8babae9a0e94f5f0436415319dae5cd1d3ce096f Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 18 Mar 2022 19:36:36 +0000 Subject: [PATCH 06/20] Update dependency nokogiri to v1.13.2 [SECURITY] --- Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index eac8ce4f6..10ae5358f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -303,7 +303,7 @@ GEM nokogiri (~> 1) rake mini_mime (1.1.1) - mini_portile2 (2.7.1) + mini_portile2 (2.8.0) minitest (5.15.0) monetize (1.9.4) money (~> 6.12) @@ -324,10 +324,10 @@ GEM newrelic_rpm (= 8.1.0) newrelic_rpm (8.1.0) nio4r (2.5.8) - nokogiri (1.13.0) - mini_portile2 (~> 2.7.0) + nokogiri (1.13.3) + mini_portile2 (~> 2.8.0) racc (~> 1.4) - nokogiri (1.13.0-x86_64-linux) + nokogiri (1.13.3-x86_64-linux) racc (~> 1.4) nori (2.6.0) omniauth (1.9.1) From db012dd7da078851d301c1f77fb52e7d918f8460 Mon Sep 17 00:00:00 2001 From: olegphenomenon Date: Fri, 11 Mar 2022 10:27:10 +0200 Subject: [PATCH 07/20] business registry contacts - endpoints for send status of contacts and receive confirmation --- .gitignore | 1 + .ruby-version | 2 +- .../api/v1/registrant/contacts_controller.rb | 11 ++ app/models/registrant_user.rb | 32 +++- config/routes.rb | 5 +- db/structure.sql | 160 ++++++++++++++++-- test/models/registrant_user_test.rb | 6 +- 7 files changed, 188 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index 3f23f1277..1c4a85f46 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ /config/application.yml /config/environments/development.rb /config/deploy.rb +/config/master.key /.idea # Do not commit one. Instead, download the latest from https://github.com/internetee/style-guide. diff --git a/.ruby-version b/.ruby-version index 94ff29cc4..75a22a26a 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.1.1 +3.0.3 diff --git a/app/controllers/api/v1/registrant/contacts_controller.rb b/app/controllers/api/v1/registrant/contacts_controller.rb index 30096ab8a..8e8b46631 100644 --- a/app/controllers/api/v1/registrant/contacts_controller.rb +++ b/app/controllers/api/v1/registrant/contacts_controller.rb @@ -34,6 +34,17 @@ module Api end end + def do_need_update_contact + result = current_registrant_user.do_need_update_contact? + render json: { update_contacts: result[:result], counter: result[:counter] } + end + + def update_company_contacts + companies = current_registrant_user.update_company_contacts + + render json: { message: 'get it', companies: companies } + end + def update logger.debug 'Received update request' logger.debug params diff --git a/app/models/registrant_user.rb b/app/models/registrant_user.rb index 5fe508125..b60a1b1a7 100644 --- a/app/models/registrant_user.rb +++ b/app/models/registrant_user.rb @@ -20,16 +20,34 @@ class RegistrantUser < User def companies(company_register = CompanyRegister::Client.new) return [] if ident.include?('-') - companies = company_register.representation_rights(citizen_personal_code: ident, - citizen_country_code: country.alpha3) - - companies = update_contacts_before_receive(companies) - companies + company_register.representation_rights(citizen_personal_code: ident, + citizen_country_code: country.alpha3) rescue CompanyRegister::NotAvailableError - return [] + [] end - def update_contacts_before_receive(companies) + def do_need_update_contact? + return { result: false, counter: 0 } if companies.blank? + + counter = 0 + companies.each do |company| + contacts = Contact.where(ident: company.registration_number, ident_country_code: 'EE') + + next if contacts.blank? + + contacts.each do |contact| + next if company.company_name == contact.name + + counter += 1 + end + end + + return { result: true, counter: counter } if counter.positive? + + { result: false, counter: 0 } + end + + def update_company_contacts return [] if companies.blank? companies.each do |company| diff --git a/config/routes.rb b/config/routes.rb index 66debd4b4..79807729a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -128,7 +128,10 @@ Rails.application.routes.draw do resources :domains, only: %i[index show], param: :uuid do resource :registry_lock, only: %i[create destroy] end - resources :contacts, only: %i[index show update], param: :uuid + resources :contacts, only: %i[index show update], param: :uuid do + get 'do_need_update_contact', to: 'contacts#do_need_update_contact', as: :do_need_update_contact + post 'update_company_contacts', to: 'contacts#update_company_contacts', as: :update_company_contacts + end resources :companies, only: %i[index] end diff --git a/db/structure.sql b/db/structure.sql index 5b842d4a4..0c8420f43 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -51,6 +51,20 @@ CREATE EXTENSION IF NOT EXISTS hstore WITH SCHEMA public; COMMENT ON EXTENSION hstore IS 'data type for storing sets of (key, value) pairs'; +-- +-- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner: - +-- + +CREATE EXTENSION IF NOT EXISTS pg_stat_statements WITH SCHEMA public; + + +-- +-- Name: EXTENSION pg_stat_statements; Type: COMMENT; Schema: -; Owner: - +-- + +COMMENT ON EXTENSION pg_stat_statements IS 'track execution statistics of all SQL statements executed'; + + -- -- Name: pgcrypto; Type: EXTENSION; Schema: -; Owner: - -- @@ -202,6 +216,8 @@ CREATE FUNCTION public.generate_zonefile(i_origin character varying) RETURNS tex SET default_tablespace = ''; +SET default_with_oids = false; + -- -- Name: account_activities; Type: TABLE; Schema: public; Owner: - -- @@ -809,7 +825,9 @@ CREATE TABLE public.dnskeys ( creator_str character varying, updator_str character varying, legacy_domain_id integer, - updated_at timestamp without time zone + updated_at timestamp without time zone, + validation_datetime timestamp without time zone, + failed_validation_reason character varying ); @@ -936,6 +954,7 @@ CREATE TABLE public.domains ( pending_json jsonb, force_delete_date date, statuses character varying[], + status_notes public.hstore, statuses_before_force_delete character varying[] DEFAULT '{}'::character varying[], upid integer, up_date timestamp without time zone, @@ -943,8 +962,7 @@ CREATE TABLE public.domains ( locked_by_registrant_at timestamp without time zone, force_delete_start timestamp without time zone, force_delete_data public.hstore, - json_statuses_history jsonb, - status_notes public.hstore + json_statuses_history jsonb ); @@ -1177,6 +1195,7 @@ CREATE TABLE public.invoices ( buyer_vat_no character varying, issue_date date NOT NULL, e_invoice_sent_at timestamp without time zone, + payment_link character varying, CONSTRAINT invoices_due_date_is_not_before_issue_date CHECK ((due_date >= issue_date)) ); @@ -2263,6 +2282,74 @@ 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: pghero_space_stats; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.pghero_space_stats ( + id bigint NOT NULL, + database text, + schema text, + relation text, + size bigint, + captured_at timestamp without time zone +); + + +-- +-- Name: pghero_space_stats_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.pghero_space_stats_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: pghero_space_stats_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.pghero_space_stats_id_seq OWNED BY public.pghero_space_stats.id; + + -- -- Name: prices; Type: TABLE; Schema: public; Owner: - -- @@ -2623,8 +2710,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 ); @@ -3166,6 +3252,20 @@ 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: pghero_space_stats id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.pghero_space_stats ALTER COLUMN id SET DEFAULT nextval('public.pghero_space_stats_id_seq'::regclass); + + -- -- Name: prices id; Type: DEFAULT; Schema: public; Owner: - -- @@ -3689,6 +3789,22 @@ 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: pghero_space_stats pghero_space_stats_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.pghero_space_stats + ADD CONSTRAINT pghero_space_stats_pkey PRIMARY KEY (id); + + -- -- Name: prices prices_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -4459,6 +4575,20 @@ 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_pghero_space_stats_on_database_and_captured_at; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_pghero_space_stats_on_database_and_captured_at ON public.pghero_space_stats USING btree (database, captured_at); + + -- -- Name: index_prices_on_zone_id; Type: INDEX; Schema: public; Owner: - -- @@ -4515,13 +4645,6 @@ CREATE INDEX index_users_on_registrar_id ON public.users USING btree (registrar_ CREATE INDEX index_validation_events_on_event_data ON public.validation_events USING gin (event_data); --- --- 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: - -- @@ -5267,15 +5390,20 @@ INSERT INTO "schema_migrations" (version) VALUES ('20210708131814'), ('20210729131100'), ('20210729134625'), -('20210827185249'), -('20211029073644'), +('20211028122103'), +('20211028125245'), +('20211029082225'), ('20211124071418'), +('20211124084308'), ('20211125181033'), ('20211125184334'), ('20211126085139'), +('20211231113934'), ('20220106123143'), ('20220113201642'), -('20220113220809'); - +('20220113220809'), +('20220124105717'), +('20220216113112'), +('20220228093211'); diff --git a/test/models/registrant_user_test.rb b/test/models/registrant_user_test.rb index 987e80c03..99618642a 100644 --- a/test/models/registrant_user_test.rb +++ b/test/models/registrant_user_test.rb @@ -41,10 +41,8 @@ class RegistrantUserTest < ActiveSupport::TestCase company = Company.new(org.ident, "ace") - company_register = Minitest::Mock.new - company_register.expect(:representation_rights, [company], [{ citizen_personal_code: '1234', - citizen_country_code: 'USA' }]) - @user.companies(company_register) + Spy.on(@user, :companies).and_return([company]) + @user.update_company_contacts org.reload assert_equal org.name, company.company_name From 85ac6c95f2a590369aee1cc142d7375a6d420213 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergei=20Ts=C3=B5ganov?= Date: Thu, 24 Mar 2022 16:27:16 +0200 Subject: [PATCH 08/20] Updated sidekiq gem version --- Gemfile | 2 +- Gemfile.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 2e728f99f..5aae015ba 100644 --- a/Gemfile +++ b/Gemfile @@ -70,7 +70,7 @@ gem 'jquery-ui-rails', '6.0.1' gem 'pdfkit' gem 'que' gem 'que-web' -gem 'sidekiq' +gem 'sidekiq', '>= 6.4.1' gem 'company_register', github: 'internetee/company_register', branch: 'master' diff --git a/Gemfile.lock b/Gemfile.lock index 10ae5358f..4c544c441 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -449,7 +449,7 @@ GEM selenium-webdriver (3.142.7) childprocess (>= 0.5, < 4.0) rubyzip (>= 1.2.2) - sidekiq (6.4.0) + sidekiq (6.4.1) connection_pool (>= 2.2.2) rack (~> 2.0) redis (>= 4.2.0) @@ -588,7 +588,7 @@ DEPENDENCIES sass-rails select2-rails (= 4.0.13) selectize-rails (= 0.12.6) - sidekiq + sidekiq (>= 6.4.1) simplecov (= 0.17.1) simpleidn (= 0.2.1) spy @@ -601,4 +601,4 @@ DEPENDENCIES wkhtmltopdf-binary (~> 0.12.5.1) BUNDLED WITH - 2.2.31 + 2.3.9 From 71655c429230ee7623758065361485762ea91567 Mon Sep 17 00:00:00 2001 From: olegphenomenon Date: Fri, 25 Mar 2022 11:56:12 +0200 Subject: [PATCH 09/20] refactored method which display count of contact --- app/models/registrant_user.rb | 11 ++-------- test/models/registrant_user_test.rb | 33 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/app/models/registrant_user.rb b/app/models/registrant_user.rb index b60a1b1a7..80b8ecab9 100644 --- a/app/models/registrant_user.rb +++ b/app/models/registrant_user.rb @@ -31,15 +31,8 @@ class RegistrantUser < User counter = 0 companies.each do |company| - contacts = Contact.where(ident: company.registration_number, ident_country_code: 'EE') - - next if contacts.blank? - - contacts.each do |contact| - next if company.company_name == contact.name - - counter += 1 - end + counter += Contact.where(ident: company.registration_number, ident_country_code: 'EE')&. + reject { |contact| contact.name == company.company_name }.size end return { result: true, counter: counter } if counter.positive? diff --git a/test/models/registrant_user_test.rb b/test/models/registrant_user_test.rb index 99618642a..2b1d6a880 100644 --- a/test/models/registrant_user_test.rb +++ b/test/models/registrant_user_test.rb @@ -61,6 +61,39 @@ class RegistrantUserTest < ActiveSupport::TestCase company_register.verify end + def test_should_return_zero_count_of_companies + assert_equal 'US-1234', @user.registrant_ident + org = contacts(:acme_ltd) + org.ident_country_code = 'EE' + org.save(validate: false) + org.reload + + company_one = Company.new(org.ident, 'Acme Ltd') + + Spy.on(@user, :companies).and_return([company_one]) + response = @user.do_need_update_contact? + org.reload + + assert_equal response[:counter], 0 + end + + def test_should_return_count_of_contact_which_should_be_updated + assert_equal 'US-1234', @user.registrant_ident + org = contacts(:acme_ltd) + org.ident_country_code = 'EE' + org.save(validate: false) + org.reload + + company_one = Company.new(org.ident, 'ace') + company_two = Company.new(org.ident, 'acer') + + Spy.on(@user, :companies).and_return([company_one, company_two]) + response = @user.do_need_update_contact? + org.reload + + assert_equal response[:counter], 2 + end + def test_returns_contacts Contact.stub(:registrant_user_contacts, %w(john jane)) do assert_equal %w(john jane), @user.contacts From e2d59085c755c483d34a610fcbae64d62e1c2c17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Fri, 25 Mar 2022 13:50:28 +0200 Subject: [PATCH 10/20] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0305aff95..57ff0b10e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +25.03.2022 +* Bulk change of business contacts' names requires now user confirmation (#2309)[https://github.com/internetee/registry/pull/2309] + 23.02.2022 * FD notes are updated when basis for FD changes [#2216](https://github.com/internetee/registry/issues/2216) * Admin: date filter end date in domain hostory is now inclusive [#2274](https://github.com/internetee/registry/issues/2274) From 48911b18b7c4beb5b0cac27400230beac16c74b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Fri, 25 Mar 2022 13:52:51 +0200 Subject: [PATCH 11/20] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57ff0b10e..a97c8f366 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ 25.03.2022 -* Bulk change of business contacts' names requires now user confirmation (#2309)[https://github.com/internetee/registry/pull/2309] +* Bulk change of business contacts' names requires now user confirmation [#2309](https://github.com/internetee/registry/pull/2309) 23.02.2022 * FD notes are updated when basis for FD changes [#2216](https://github.com/internetee/registry/issues/2216) From e4d56fe576622e1ab5d248ee91a79968b2422922 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 25 Mar 2022 13:03:54 +0000 Subject: [PATCH 12/20] Update dependency pg to v1.3.4 --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 2e728f99f..9b1981376 100644 --- a/Gemfile +++ b/Gemfile @@ -17,7 +17,7 @@ gem 'figaro', '~> 1.2' # model related gem 'paper_trail', '~> 12.1' -gem 'pg', '1.3.3' +gem 'pg', '1.3.4' # 1.8 is for Rails < 5.0 gem 'ransack', '~> 2.6.0' gem 'truemail', '~> 2.4' # validates email by regexp, mail server existence and address existence diff --git a/Gemfile.lock b/Gemfile.lock index 10ae5358f..02034696a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -351,7 +351,7 @@ GEM activerecord (>= 5.2) request_store (~> 1.1) pdfkit (0.8.5) - pg (1.3.3) + pg (1.3.4) pg_query (2.1.2) google-protobuf (>= 3.17.1) pghero (2.8.1) @@ -574,7 +574,7 @@ DEPENDENCIES omniauth-tara! paper_trail (~> 12.1) pdfkit - pg (= 1.3.3) + pg (= 1.3.4) pg_query (>= 0.9.0) pghero pry (= 0.14.1) From e5688e843d7c9884728bf5dc698d5499dae22950 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Thu, 31 Mar 2022 16:21:43 +0300 Subject: [PATCH 13/20] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a97c8f366..ea1333016 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +31.03.2022 +* Sidekiq update to 6.4.1 [#2322](https://github.com/internetee/registry/pull/2322) + 25.03.2022 * Bulk change of business contacts' names requires now user confirmation [#2309](https://github.com/internetee/registry/pull/2309) From 3f1a84f67a1ca9afeb31ed73ea5814e8a2a9831f Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 1 Apr 2022 01:22:24 +0000 Subject: [PATCH 14/20] Update dependency pg to v1.3.5 --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 672291cf5..f172c869a 100644 --- a/Gemfile +++ b/Gemfile @@ -17,7 +17,7 @@ gem 'figaro', '~> 1.2' # model related gem 'paper_trail', '~> 12.1' -gem 'pg', '1.3.4' +gem 'pg', '1.3.5' # 1.8 is for Rails < 5.0 gem 'ransack', '~> 2.6.0' gem 'truemail', '~> 2.4' # validates email by regexp, mail server existence and address existence diff --git a/Gemfile.lock b/Gemfile.lock index 618c4c161..73b1d3526 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -351,7 +351,7 @@ GEM activerecord (>= 5.2) request_store (~> 1.1) pdfkit (0.8.5) - pg (1.3.4) + pg (1.3.5) pg_query (2.1.2) google-protobuf (>= 3.17.1) pghero (2.8.1) @@ -574,7 +574,7 @@ DEPENDENCIES omniauth-tara! paper_trail (~> 12.1) pdfkit - pg (= 1.3.4) + pg (= 1.3.5) pg_query (>= 0.9.0) pghero pry (= 0.14.1) From a55797eef6102ea102217fdc0012ab43129e313d Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 1 Apr 2022 04:31:33 +0000 Subject: [PATCH 15/20] Update dependency puma to v5.6.4 [SECURITY] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 73b1d3526..a99b31189 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -360,7 +360,7 @@ GEM coderay (~> 1.1) method_source (~> 1.0) public_suffix (4.0.6) - puma (5.6.2) + puma (5.6.4) nio4r (~> 2.0) que (0.14.3) que-web (0.7.2) From 20c5b4946c8d81910be95116c11b8060dd2b4869 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 1 Apr 2022 17:14:50 +0000 Subject: [PATCH 16/20] Update actions/checkout action to v3 --- .github/workflows/build_baseimage_with_gems.yml | 2 +- .github/workflows/ruby.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_baseimage_with_gems.yml b/.github/workflows/build_baseimage_with_gems.yml index 3487e838c..e6f72594a 100644 --- a/.github/workflows/build_baseimage_with_gems.yml +++ b/.github/workflows/build_baseimage_with_gems.yml @@ -17,7 +17,7 @@ jobs: steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Login to container registry env: diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index dd71c4bee..8a168aec7 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -22,7 +22,7 @@ jobs: continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} From 8397950329dc09b9d96c42bf547e244351c1659e Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 4 Apr 2022 11:39:51 +0000 Subject: [PATCH 17/20] Update actions/download-artifact action to v3 --- .github/workflows/ruby.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 8a168aec7..f275d8a96 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -104,7 +104,7 @@ jobs: - name: Give test coverage reporter executable permissions run: chmod +x cc-test-reporter - - uses: actions/download-artifact@v2.1.0 + - uses: actions/download-artifact@v3.0.0 with: name: coverage-${{ matrix.ruby }} path: coverage From a54a822d912922b4a03e545921650e070aa59021 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 4 Apr 2022 11:39:54 +0000 Subject: [PATCH 18/20] Update actions/upload-artifact action to v3 --- .github/workflows/ruby.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 8a168aec7..d872eed93 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -79,7 +79,7 @@ jobs: - name: Save coverage run: ./cc-test-reporter format-coverage --output coverage/codeclimate.${{ matrix.ruby }}.json - - uses: actions/upload-artifact@v2.3.1 + - uses: actions/upload-artifact@v3.0.0 with: name: coverage-${{ matrix.ruby }} path: coverage/codeclimate.${{ matrix.ruby }}.json From 076cc269893ca338cf011894c473c6cb614cd920 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 4 Apr 2022 11:53:26 +0000 Subject: [PATCH 19/20] Update actions/upload-artifact action to v3 --- .github/workflows/ruby.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index f275d8a96..d50636e26 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -79,7 +79,7 @@ jobs: - name: Save coverage run: ./cc-test-reporter format-coverage --output coverage/codeclimate.${{ matrix.ruby }}.json - - uses: actions/upload-artifact@v2.3.1 + - uses: actions/upload-artifact@v3.0.0 with: name: coverage-${{ matrix.ruby }} path: coverage/codeclimate.${{ matrix.ruby }}.json From 9c848bb4dc4c427a538b00e1b431df35c7ba375a Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 4 Apr 2022 12:17:32 +0000 Subject: [PATCH 20/20] Update dependency data_migrate to v8 --- Gemfile | 2 +- Gemfile.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index f172c869a..c907eb267 100644 --- a/Gemfile +++ b/Gemfile @@ -40,7 +40,7 @@ gem 'select2-rails', '4.0.13' # for autocomplete gem 'selectize-rails', '0.12.6' # include selectize.js for select # registry specfic -gem 'data_migrate', '~> 7.0' +gem 'data_migrate', '~> 8.0' gem 'dnsruby', '~> 1.61' gem 'isikukood' # for EE-id validation gem 'money-rails' diff --git a/Gemfile.lock b/Gemfile.lock index a99b31189..f7e9afa7e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -193,7 +193,7 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.1.9) + concurrent-ruby (1.1.10) connection_pool (2.2.5) countries (4.0.1) i18n_data (~> 0.13.0) @@ -205,7 +205,7 @@ GEM daemons-rails (1.2.1) daemons multi_json (~> 1.0) - data_migrate (7.0.2) + data_migrate (8.0.0) activerecord (>= 5.0) railties (>= 5.0) database_cleaner (2.0.1) @@ -289,7 +289,7 @@ GEM kaminari-core (1.2.1) libxml-ruby (3.2.1) logger (1.4.3) - loofah (2.12.0) + loofah (2.16.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) @@ -480,7 +480,7 @@ GEM attr_required (>= 0.0.5) httpclient (>= 2.4) temple (0.8.2) - thor (1.1.0) + thor (1.2.1) tilt (2.0.10) truemail (2.4.9) simpleidn (~> 0.2.1) @@ -544,7 +544,7 @@ DEPENDENCIES company_register! countries daemons-rails (= 1.2.1) - data_migrate (~> 7.0) + data_migrate (~> 8.0) database_cleaner devise (~> 4.8) digidoc_client!