From 1d5a79f406379dc4052a6d9382e83d12f7a1d967 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Thu, 7 Apr 2016 16:45:44 +0300 Subject: [PATCH 01/10] Story#117124725 - raise an error ConfirmingRegistrant Change job --- app/jobs/domain_update_confirm_job.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/jobs/domain_update_confirm_job.rb b/app/jobs/domain_update_confirm_job.rb index 098b9853e..67007d334 100644 --- a/app/jobs/domain_update_confirm_job.rb +++ b/app/jobs/domain_update_confirm_job.rb @@ -7,8 +7,13 @@ class DomainUpdateConfirmJob < Que::Job case action when RegistrantVerification::CONFIRMED domain.poll_message!(:poll_pending_update_confirmed_by_registrant) + raise_errors!(domain) + domain.apply_pending_update! + raise_errors!(domain) + domain.clean_pendings! + raise_errors!(domain) when RegistrantVerification::REJECTED domain.send_mail :pending_update_rejected_notification_for_new_registrant domain.poll_message!(:poll_pending_update_rejected_by_registrant) @@ -17,4 +22,8 @@ class DomainUpdateConfirmJob < Que::Job destroy # it's best to destroy the job in the same transaction end end + + def raise_errors!(domain) + throw "domain #{domain.name} failed with errors #{domain.errors.full_messages}" if domain.errors.any? + end end From a091c62264ba77085cfe0872b586c5e1621b072c Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Fri, 8 Apr 2016 14:58:56 +0300 Subject: [PATCH 02/10] Story#117124725 - generate emails of apply_pending_update! only when everything is ok --- app/mailers/domain_mailer.rb | 30 +++++++++++++-- app/models/domain_mail_model.rb | 21 ---------- app/models/epp/domain.rb | 10 +++-- ...d_notification_for_new_registrant.html.erb | 36 +++++++++--------- ...d_notification_for_new_registrant.text.erb | 38 ++++++++++--------- ...d_notification_for_old_registrant.html.erb | 36 +++++++++--------- ...d_notification_for_old_registrant.text.erb | 36 +++++++++--------- spec/mailers/domain_mailer_spec.rb | 4 +- 8 files changed, 108 insertions(+), 103 deletions(-) diff --git a/app/mailers/domain_mailer.rb b/app/mailers/domain_mailer.rb index 28e232a8c..fb2c0e851 100644 --- a/app/mailers/domain_mailer.rb +++ b/app/mailers/domain_mailer.rb @@ -9,12 +9,34 @@ class DomainMailer < ApplicationMailer compose_from(params) end - def registrant_updated_notification_for_new_registrant(params) - compose_from(params) + + def registrant_updated_notification_for_new_registrant(domain_id, old_registrant_id, new_registrant_id, should_deliver) + @domain = Domain.find_by(id: domain_id) + return unless @domain + return if delivery_off?(@domain, should_deliver) + + @old_registrant = Registrant.find(old_registrant_id) + @new_registrant = Registrant.find(new_registrant_id) + + return if whitelist_blocked?(@new_registrant.email) + mail(to: format(@new_registrant.email), + subject: "#{I18n.t(:registrant_updated_notification_for_new_registrant_subject, + name: @domain.name)} [#{@domain.name}]") end - def registrant_updated_notification_for_old_registrant(params) - compose_from(params) + + def registrant_updated_notification_for_old_registrant(domain_id, old_registrant_id, new_registrant_id, should_deliver) + domain = Domain.find_by(id: domain_id) + return unless domain + return if delivery_off?(@domain, should_deliver) + + @old_registrant = Registrant.find(old_registrant_id) + @new_registrant = Registrant.find(new_registrant_id) + + return if whitelist_blocked?(@old_registrant.email) + mail(to: format(@old_registrant.email), + subject: "#{I18n.t(:registrant_updated_notification_for_old_registrant_subject, + name: @domain.name)} [#{@domain.name}]") end def pending_update_rejected_notification_for_new_registrant(params) diff --git a/app/models/domain_mail_model.rb b/app/models/domain_mail_model.rb index 46309ad52..d443d8783 100644 --- a/app/models/domain_mail_model.rb +++ b/app/models/domain_mail_model.rb @@ -20,28 +20,7 @@ class DomainMailModel domain_info compose end - - def registrant_updated_notification_for_new_registrant - registrant - subject(:registrant_updated_notification_for_new_registrant_subject) - domain_info - compose - end - def registrant_updated_notification_for_old_registrant - registrant_pending - registrant_old - subject(:registrant_updated_notification_for_old_registrant_subject) - new_registrant = Registrant.find @domain.pending_json['new_registrant_id'] - @params[:registrant_name] = new_registrant.name - @params[:registrant_ident] = new_registrant.ident - @params[:registrant_priv] = new_registrant.priv? - @params[:registrant_email] = new_registrant.email - @params[:registrant_street] = new_registrant.street - @params[:registrant_city] = new_registrant.city - @params[:registrant_country] = new_registrant.country.name - compose - end def pending_update_rejected_notification_for_new_registrant registrant_pending diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 1f2dd2d54..2905bd968 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -525,19 +525,21 @@ class Epp::Domain < Domain preclean_pendings user = ApiUser.find(pending_json['current_user_id']) frame = Nokogiri::XML(pending_json['frame']) + old_registrant_id = registrant_id self.deliver_emails = true # turn on email delivery self.statuses.delete(DomainStatus::PENDING_UPDATE) ::PaperTrail.whodunnit = user.id_role_username # updator str should be the request originator not the approval user - send_mail :registrant_updated_notification_for_old_registrant return unless update(frame, user, false) clean_pendings! - send_mail :registrant_updated_notification_for_new_registrant - WhoisRecord.find_by(domain_id: id).save # need to reload model - save! # for notification if everything fails + + WhoisRecord.find_by(domain_id: id).save # need to reload model + DomainMailer.registrant_updated_notification_for_old_registrant(id, old_registrant_id, registrant_id, should_deliver) + DomainMailer.registrant_updated_notification_for_new_registrant(id, old_registrant_id, registrant_id, should_deliver) + true end diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.html.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.html.erb index c7d464f43..a654b2f80 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.html.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.html.erb @@ -1,18 +1,18 @@ Tere,

-Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud. +Domeeni <%= @domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.

Uue registreerija andmed:
-Nimi: <%= @params[:registrant_name] %>
-<% if @params[:registrant_priv] %> -Isikukood: <%= @params[:registrant_ident] %>
+Nimi: <%= @new_registrant.name %>
+<% if @new_registrant.priv? %> + Isikukood: <%= @new_registrant.ident %>
<% else %> -Äriregistrikood: <%= @params[:registrant_ident] %>
+ Äriregistrikood: <%= @new_registrant.ident %>
<% end %> -Epost: <%= @params[:registrant_email] %>
-Tänav: <%= @params[:registrant_street] %>
-Linn: <%= @params[:registrant_city] %>
-Riik: <%= @params[:registrant_country] %> +Epost: <%= @new_registrant.email %>
+Tänav: <%= @new_registrant.street %>
+Linn: <%= @new_registrant.city %>
+Riik: <%= @new_registrant.country.name %>

Lugupidamisega
Eesti Interneti SA @@ -21,19 +21,19 @@ Eesti Interneti SA

Hi,

-Process for changing registrant of the domain <%= @params[:name] %> has been approved and the data in the registry is updated. +Process for changing registrant of the domain <%= @domain.name %> has been approved and the data in the registry is updated.

New registrant:
-Name: <%= @params[:registrant_name] %>
-<% if @params[:registrant_priv] %> -Personal code: <%= @params[:registrant_ident] %>
+Name: <%= @new_registrant.name %>
+<% if @new_registrant.priv? %> + Personal code: <%= @new_registrant.ident %>
<% else %> -Business Registry code: <%= @params[:registrant_ident] %>
+ Business Registry code: <%= @new_registrant.ident %>
<% end %> -E-mail: <%= @params[:registrant_email] %>
-Street: <%= @params[:registrant_street] %>
-City: <%= @params[:registrant_city] %>
-Country: <%= @params[:registrant_country] %> +E-mail: <%= @new_registrant.email %>
+Street: <%= @new_registrant.street %>
+City: <%= @new_registrant.city %>
+Country: <%= @new_registrant.country.name %>

Best Regards,
Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.text.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.text.erb index 115655897..64db26ec7 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.text.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_new_registrant.text.erb @@ -1,18 +1,19 @@ Tere, -Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud. +Domeeni <%= @domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud. Uue registreerija andmed: -Nimi: <%= @params[:registrant_name] %> -<% if @params[:registrant_priv] %> -Isikukood: <%= @params[:registrant_ident] %> +Nimi: <%= @new_registrant.name %> + +<% if @new_registrant.priv? %> + Isikukood: <%= @new_registrant.ident %> <% else %> -Äriregistrikood: <%= @params[:registrant_ident] %> + Äriregistrikood: <%= @new_registrant.ident %> <% end %> -Epost: <%= @params[:registrant_email] %> -Tänav: <%= @params[:registrant_street] %> -Linn: <%= @params[:registrant_city] %> -Riik: <%= @params[:registrant_country] %> +Epost: <%= @new_registrant.email %> +Tänav: <%= @new_registrant.street %> +Linn: <%= @new_registrant.city %> +Riik: <%= @new_registrant.country.name %> Lugupidamisega Eesti Interneti SA @@ -21,19 +22,20 @@ Eesti Interneti SA Hi, -Process for changing registrant of the domain <%= @params[:name] %> has been approved and the data in the registry is updated. +Process for changing registrant of the domain <%= @domain.name %> has been approved and the data in the registry is updated. New registrant: -Name: <%= @params[:registrant_name] %> -<% if @params[:registrant_priv] %> -Personal code: <%= @params[:registrant_ident] %> +Name: <%= @new_registrant.name %> + +<% if @new_registrant.priv? %> + Personal code: <%= @new_registrant.ident %> <% else %> -Business Registry code: <%= @params[:registrant_ident] %> + Business Registry code: <%= @new_registrant.ident %> <% end %> -E-mail: <%= @params[:registrant_email] %> -Street: <%= @params[:registrant_street] %> -City: <%= @params[:registrant_city] %> -Country: <%= @params[:registrant_country] %> +E-mail: <%= @new_registrant.email %> +Street: <%= @new_registrant.street %> +City: <%= @new_registrant.city %> +Country: <%= @new_registrant.country.name %> Best Regards, Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb index b41e1f1eb..180988f08 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.html.erb @@ -1,18 +1,18 @@ Tere,

-Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud. +Domeeni <%= @domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud.

Uue registreerija andmed:
-Nimi: <%= @params[:new_registrant_name] %>
-<% if @params[:registrant_priv] %> -Isikukood: <%= @params[:registrant_ident] %>
+Nimi: <%= @new_registrant.name %>
+<% if @new_registrant.priv? %> +Isikukood: <%= @new_registrant.ident %>
<% else %> -Äriregistrikood: <%= @params[:registrant_ident] %>
+Äriregistrikood: <%= @new_registrant.ident %>
<% end %> -Epost: <%= @params[:registrant_email] %>
-Tänav: <%= @params[:registrant_street] %>
-Linn: <%= @params[:registrant_city] %>
-Riik: <%= @params[:registrant_country] %> +Epost: <%= @new_registrant.email %>
+Tänav: <%= @new_registrant.street %>
+Linn: <%= @new_registrant.city %>
+Riik: <%= @new_registrant.country.name %>

Lugupidamisega
Eesti Interneti SA @@ -21,19 +21,19 @@ Eesti Interneti SA

Hi,

-Process for changing registrant of the domain <%= @params[:name] %> has been approved and the data in the registry is updated. +Process for changing registrant of the domain <%= @domain.name %> has been approved and the data in the registry is updated.

New registrant:
-Name: <%= @params[:new_registrant_name] %>
-<% if @params[:registrant_priv] %> -Personal code: <%= @params[:registrant_ident] %>
+Name: <%= @new_registrant.name %>
+<% if @new_registrant.priv? %> +Personal code: <%= @new_registrant.ident %>
<% else %> -Business Registry code: <%= @params[:registrant_ident] %>
+Business Registry code: <%= @new_registrant.ident %>
<% end %> -E-mail: <%= @params[:registrant_email] %>
-Street: <%= @params[:registrant_street] %>
-City: <%= @params[:registrant_city] %>
-Country: <%= @params[:registrant_country] %> +E-mail: <%= @new_registrant.email %>
+Street: <%= @new_registrant.street %>
+City: <%= @new_registrant.city %>
+Country: <%= @new_registrant.country.name %>

Best Regards,
Estonian Internet Foundation diff --git a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb index c2efa5af9..1d45fb5e0 100644 --- a/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb +++ b/app/views/mailers/domain_mailer/registrant_updated_notification_for_old_registrant.text.erb @@ -1,19 +1,19 @@ Tere, -Domeeni <%= @params[:name] %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud. +Domeeni <%= @domain.name %> registreerija vahetuse taotlus on kinnitatud ning andmed registris uuendatud. Uue registreerija andmed: -Nimi: <%= @params[:new_registrant_name] %> +Nimi: <%= @new_registrant.name %> -<% if @params[:registrant_priv] %> -Isikukood: <%= @params[:registrant_ident] %> +<% if @new_registrant.priv? %> +Isikukood: <%= @new_registrant.ident %> <% else %> -Äriregistrikood: <%= @params[:registrant_ident] %> +Äriregistrikood: <%= @new_registrant.ident %> <% end %> -Epost: <%= @params[:registrant_email] %> -Tänav: <%= @params[:registrant_street] %> -Linn: <%= @params[:registrant_city] %> -Riik: <%= @params[:registrant_country] %> +Epost: <%= @new_registrant.email %> +Tänav: <%= @new_registrant.street %> +Linn: <%= @new_registrant.city %> +Riik: <%= @new_registrant.country.name %> Lugupidamisega Eesti Interneti SA @@ -22,20 +22,20 @@ Eesti Interneti SA Hi, -Process for changing registrant of the domain <%= @params[:name] %> has been approved and the data in the registry is updated. +Process for changing registrant of the domain <%= @domain.name %> has been approved and the data in the registry is updated. New registrant: -Name: <%= @params[:new_registrant_name] %> +Name: <%= @new_registrant.name %> -<% if @params[:registrant_priv] %> -Personal code: <%= @params[:registrant_ident] %> +<% if @new_registrant.priv? %> +Personal code: <%= @new_registrant.ident %> <% else %> -Business Registry code: <%= @params[:registrant_ident] %> +Business Registry code: <%= @new_registrant.ident %> <% end %> -E-mail: <%= @params[:registrant_email] %> -Street: <%= @params[:registrant_street] %> -City: <%= @params[:registrant_city] %> -Country: <%= @params[:registrant_country] %> +E-mail: <%= @new_registrant.email %> +Street: <%= @new_registrant.street %> +City: <%= @new_registrant.city %> +Country: <%= @new_registrant.country.name %> Best Regards, Estonian Internet Foundation diff --git a/spec/mailers/domain_mailer_spec.rb b/spec/mailers/domain_mailer_spec.rb index 3f645f7e0..9963fdd38 100644 --- a/spec/mailers/domain_mailer_spec.rb +++ b/spec/mailers/domain_mailer_spec.rb @@ -153,7 +153,7 @@ describe DomainMailer do @registrant = Fabricate(:registrant, email: 'test@example.com') @domain = Fabricate(:domain, registrant: @registrant) @domain.deliver_emails = true - @mail = DomainMailer.registrant_updated_notification_for_new_registrant(@domain.id, deliver_emails) + @mail = DomainMailer.registrant_updated_notification_for_new_registrant(@domain.id, @registrant.id, @registrant.id, deliver_emails) end it 'should render email subject' do @@ -178,7 +178,7 @@ describe DomainMailer do @registrant = Fabricate(:registrant, email: 'test@example.com') @domain = Fabricate(:domain, registrant: @registrant) @domain.deliver_emails = true - @mail = DomainMailer.registrant_updated_notification_for_old_registrant(@domain.id, deliver_emails) + @mail = DomainMailer.registrant_updated_notification_for_old_registrant(@domain.id, @registrant.id, @registrant.id, deliver_emails) end it 'should render email subject' do From 912b820f82ab1d6e855cbd32f6a7c62673165393 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Fri, 8 Apr 2016 15:12:56 +0300 Subject: [PATCH 03/10] Story#117124725 - generate emails of apply_pending_update! only when everything is ok --- app/models/epp/domain.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 2905bd968..738fd1077 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -537,8 +537,8 @@ class Epp::Domain < Domain save! # for notification if everything fails WhoisRecord.find_by(domain_id: id).save # need to reload model - DomainMailer.registrant_updated_notification_for_old_registrant(id, old_registrant_id, registrant_id, should_deliver) - DomainMailer.registrant_updated_notification_for_new_registrant(id, old_registrant_id, registrant_id, should_deliver) + DomainMailer.registrant_updated_notification_for_old_registrant(id, old_registrant_id, registrant_id, deliver_emails) + DomainMailer.registrant_updated_notification_for_new_registrant(id, old_registrant_id, registrant_id, deliver_emails) true end From af81adee57b98a36f63816c77c7f1514e2fed84b Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Fri, 8 Apr 2016 15:29:37 +0300 Subject: [PATCH 04/10] Story#117124725 - generate emails of apply_pending_update! only when everything is ok --- app/models/epp/domain.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 738fd1077..2092f4480 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -537,8 +537,8 @@ class Epp::Domain < Domain save! # for notification if everything fails WhoisRecord.find_by(domain_id: id).save # need to reload model - DomainMailer.registrant_updated_notification_for_old_registrant(id, old_registrant_id, registrant_id, deliver_emails) - DomainMailer.registrant_updated_notification_for_new_registrant(id, old_registrant_id, registrant_id, deliver_emails) + DomainMailer.registrant_updated_notification_for_old_registrant(id, old_registrant_id, registrant_id, true).deliver + DomainMailer.registrant_updated_notification_for_new_registrant(id, old_registrant_id, registrant_id, true).deliver true end From 28bed16539f03724792f238cf5e8cd3c96c29fa8 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Fri, 8 Apr 2016 15:34:43 +0300 Subject: [PATCH 05/10] Story#117124725 - old mailer domain variable wasn't global --- app/mailers/domain_mailer.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/mailers/domain_mailer.rb b/app/mailers/domain_mailer.rb index fb2c0e851..afdfe89fc 100644 --- a/app/mailers/domain_mailer.rb +++ b/app/mailers/domain_mailer.rb @@ -26,8 +26,8 @@ class DomainMailer < ApplicationMailer def registrant_updated_notification_for_old_registrant(domain_id, old_registrant_id, new_registrant_id, should_deliver) - domain = Domain.find_by(id: domain_id) - return unless domain + @domain = Domain.find_by(id: domain_id) + return unless @domain return if delivery_off?(@domain, should_deliver) @old_registrant = Registrant.find(old_registrant_id) From ce124beb8f7e4985aa93eb31bea4ec2ec7f64e2b Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Wed, 13 Apr 2016 10:50:41 +0300 Subject: [PATCH 06/10] Story#117124725 - show errors if something happens --- app/jobs/domain_delete_confirm_job.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/jobs/domain_delete_confirm_job.rb b/app/jobs/domain_delete_confirm_job.rb index cce230234..e147e3aa8 100644 --- a/app/jobs/domain_delete_confirm_job.rb +++ b/app/jobs/domain_delete_confirm_job.rb @@ -3,17 +3,30 @@ class DomainDeleteConfirmJob < Que::Job # it's recommended to keep transaction against job table as short as possible. ActiveRecord::Base.transaction do domain = Epp::Domain.find(domain_id) + case action when RegistrantVerification::CONFIRMED domain.poll_message!(:poll_pending_delete_confirmed_by_registrant) domain.apply_pending_delete! + raise_errors!(domain) + when RegistrantVerification::REJECTED - DomainMailer.pending_delete_rejected_notification(domain_id, true).deliver domain.statuses.delete(DomainStatus::PENDING_DELETE_CONFIRMATION) domain.poll_message!(:poll_pending_delete_rejected_by_registrant) + domain.cancel_pending_delete + domain.save(validate: false) + raise_errors!(domain) + + DomainMailer.pending_delete_rejected_notification(domain_id, true).deliver end + destroy # it's best to destroy the job in the same transaction end end + + + def raise_errors!(domain) + throw "domain #{domain.name} failed with errors #{domain.errors.full_messages}" if domain.errors.any? + end end From 5373c76c4087b073685eb54226024ce1547ea5c0 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Thu, 14 Apr 2016 14:32:32 +0300 Subject: [PATCH 07/10] Story#116962601 - faster epp logs --- app/controllers/admin/epp_logs_controller.rb | 6 +++++- app/controllers/admin/repp_logs_controller.rb | 6 +++++- db/migrate/20160414110443_add_time_indexing_to_epp_log.rb | 6 ++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20160414110443_add_time_indexing_to_epp_log.rb diff --git a/app/controllers/admin/epp_logs_controller.rb b/app/controllers/admin/epp_logs_controller.rb index b14a99766..e9d8542ed 100644 --- a/app/controllers/admin/epp_logs_controller.rb +++ b/app/controllers/admin/epp_logs_controller.rb @@ -5,7 +5,11 @@ class Admin::EppLogsController < AdminController def index @q = ApiLog::EppLog.search(params[:q]) @q.sorts = 'id desc' if @q.sorts.empty? - @epp_logs = @q.result.page(params[:page]) + + @epp_logs = @q.result + @epp_logs = @epp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_gteq])) if params[:q][:created_at_gteq] + @epp_logs = @epp_logs.where("extract(epoch from created_at) <= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_lteq])) if params[:q][:created_at_lteq] + @epp_logs = @epp_logs.page(params[:page]) end def show diff --git a/app/controllers/admin/repp_logs_controller.rb b/app/controllers/admin/repp_logs_controller.rb index 8e904007a..2b28c7227 100644 --- a/app/controllers/admin/repp_logs_controller.rb +++ b/app/controllers/admin/repp_logs_controller.rb @@ -5,7 +5,11 @@ class Admin::ReppLogsController < AdminController def index @q = ApiLog::ReppLog.search(params[:q]) @q.sorts = 'id desc' if @q.sorts.empty? - @repp_logs = @q.result.page(params[:page]) + + @repp_logs = @q.result + @repp_logs = @repp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_gteq])) if params[:q][:created_at_gteq] + @repp_logs = @repp_logs.where("extract(epoch from created_at) <= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_lteq])) if params[:q][:created_at_lteq] + @repp_logs = @repp_logs.page(params[:page]) end def show diff --git a/db/migrate/20160414110443_add_time_indexing_to_epp_log.rb b/db/migrate/20160414110443_add_time_indexing_to_epp_log.rb new file mode 100644 index 000000000..30e4d155e --- /dev/null +++ b/db/migrate/20160414110443_add_time_indexing_to_epp_log.rb @@ -0,0 +1,6 @@ +class AddTimeIndexingToEppLog < ActiveRecord::Migration + def change + ApiLog::EppLog.connection.execute( "CREATE INDEX CONCURRENTLY epp_logs_created_at ON epp_logs USING btree (extract(epoch from created_at));") + ApiLog::ReppLog.connection.execute("CREATE INDEX CONCURRENTLY repp_logs_created_at ON repp_logs USING btree (extract(epoch from created_at));") + end +end From 57be19a41a01f330ca88e70e4c2f3bd9d69bdbf5 Mon Sep 17 00:00:00 2001 From: Vladimir Krylov Date: Thu, 14 Apr 2016 14:50:48 +0300 Subject: [PATCH 08/10] Story#116962601 - faster epp logs (check for presence) --- app/controllers/admin/epp_logs_controller.rb | 4 ++-- app/controllers/admin/repp_logs_controller.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/epp_logs_controller.rb b/app/controllers/admin/epp_logs_controller.rb index e9d8542ed..46740a8d9 100644 --- a/app/controllers/admin/epp_logs_controller.rb +++ b/app/controllers/admin/epp_logs_controller.rb @@ -7,8 +7,8 @@ class Admin::EppLogsController < AdminController @q.sorts = 'id desc' if @q.sorts.empty? @epp_logs = @q.result - @epp_logs = @epp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_gteq])) if params[:q][:created_at_gteq] - @epp_logs = @epp_logs.where("extract(epoch from created_at) <= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_lteq])) if params[:q][:created_at_lteq] + @epp_logs = @epp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_gteq])) if params[:q][:created_at_gteq].present? + @epp_logs = @epp_logs.where("extract(epoch from created_at) <= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_lteq])) if params[:q][:created_at_lteq].present? @epp_logs = @epp_logs.page(params[:page]) end diff --git a/app/controllers/admin/repp_logs_controller.rb b/app/controllers/admin/repp_logs_controller.rb index 2b28c7227..ff306b0fc 100644 --- a/app/controllers/admin/repp_logs_controller.rb +++ b/app/controllers/admin/repp_logs_controller.rb @@ -7,8 +7,8 @@ class Admin::ReppLogsController < AdminController @q.sorts = 'id desc' if @q.sorts.empty? @repp_logs = @q.result - @repp_logs = @repp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_gteq])) if params[:q][:created_at_gteq] - @repp_logs = @repp_logs.where("extract(epoch from created_at) <= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_lteq])) if params[:q][:created_at_lteq] + @repp_logs = @repp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_gteq])) if params[:q][:created_at_gteq].present? + @repp_logs = @repp_logs.where("extract(epoch from created_at) <= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_lteq])) if params[:q][:created_at_lteq].present? @repp_logs = @repp_logs.page(params[:page]) end From c09c039f3cac8658ee591e3b889ea151d485caae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Fri, 15 Apr 2016 10:05:57 +0300 Subject: [PATCH 09/10] changed pending update and delete rejection messages [bug 117124725] --- config/locales/en.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 6372d401d..fd864ddf3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -827,16 +827,16 @@ en: domain_registrant_change_confirmed_body: 'You have successfully submitted domain registrant change confirmation. You will receive email confirmation.' registrant_domain_verification_confirmed: 'Domain registrant change has successfully received.' registrant_domain_verification_confirmed_failed: 'Something went wrong.' - domain_registrant_change_rejected_title: 'Domain registrant change has been rejected' - domain_registrant_change_rejected_body: 'You have rejected domain registrant change.' + domain_registrant_change_rejected_title: 'Domain registrant change rejection has been received' + domain_registrant_change_rejected_body: 'You have rejected domain registrant change. You will receive confirmation by email.' registrant_domain_verification_rejected: 'Domain registrant change has been rejected successfully.' registrant_domain_verification_rejected_failed: 'Something went wrong.' domain_delete_title: 'Please confirm or reject domain deletation' domain_delete_body: 'There is a request to delete a domain. Before doing it we need your confirmation.' domain_delete_confirmed_title: 'Domain deletion has been received successfully' domain_delete_confirmed_body: 'You have successfully submitted delete confirmation. You will receive registry final confirmation to email.' - domain_delete_rejected_title: 'Domain deletion has been rejected successfully' - domain_delete_rejected_body: 'You have rejected domain deletion.' + domain_delete_rejected_title: 'Domain deletion rejection has been received successfully' + domain_delete_rejected_body: 'You have rejected pending domain deletion. You will receive confirmation by email.' no_permission: 'No permission' access_denied: 'Access denied' common_name: 'Common name' From 8e1ce321438345b5b5dfcfa9526b34e7bcc5e872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20V=C3=B5hmar?= Date: Fri, 15 Apr 2016 11:10:40 +0300 Subject: [PATCH 10/10] fixed incorrect pending delete confirm page messages [bug 117124725] --- .../registrant/domain_delete_confirms_controller.rb | 8 ++++---- config/locales/en.yml | 6 +++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/controllers/registrant/domain_delete_confirms_controller.rb b/app/controllers/registrant/domain_delete_confirms_controller.rb index f6f05d628..209456808 100644 --- a/app/controllers/registrant/domain_delete_confirms_controller.rb +++ b/app/controllers/registrant/domain_delete_confirms_controller.rb @@ -22,18 +22,18 @@ class Registrant::DomainDeleteConfirmsController < RegistrantController verification_token: params[:token]) if params[:rejected] if @registrant_verification.domain_registrant_delete_reject! - flash[:notice] = t(:registrant_domain_verification_rejected) + flash[:notice] = t(:registrant_domain_delete_rejected) redirect_to registrant_domain_delete_confirm_path(@domain.id, rejected: true) else - flash[:alert] = t(:registrant_domain_verification_rejected_failed) + flash[:alert] = t(:registrant_domain_delete_rejected_failed) return render 'show' end elsif params[:confirmed] if @registrant_verification.domain_registrant_delete_confirm! - flash[:notice] = t(:registrant_domain_verification_confirmed) + flash[:notice] = t(:registrant_domain_delete_confirmed) redirect_to registrant_domain_delete_confirm_path(@domain.id, confirmed: true) else - flash[:alert] = t(:registrant_domain_verification_confirmed_failed) + flash[:alert] = t(:registrant_domain_delete_confirmed_failed) return render 'show' end end diff --git a/config/locales/en.yml b/config/locales/en.yml index fd864ddf3..de5891c77 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -831,10 +831,14 @@ en: domain_registrant_change_rejected_body: 'You have rejected domain registrant change. You will receive confirmation by email.' registrant_domain_verification_rejected: 'Domain registrant change has been rejected successfully.' registrant_domain_verification_rejected_failed: 'Something went wrong.' - domain_delete_title: 'Please confirm or reject domain deletation' + domain_delete_title: 'Please confirm or reject domain deletion' domain_delete_body: 'There is a request to delete a domain. Before doing it we need your confirmation.' + registrant_domain_delete_confirmed: 'Setting the domain up for deletion...' + registrant_domain_delete_confirmed_failed: 'Something went wrong.' domain_delete_confirmed_title: 'Domain deletion has been received successfully' domain_delete_confirmed_body: 'You have successfully submitted delete confirmation. You will receive registry final confirmation to email.' + registrant_domain_delete_rejected: 'Rejecting the domain deletion...' + registrant_domain_delete_rejected_failed: 'Something went wrong.' domain_delete_rejected_title: 'Domain deletion rejection has been received successfully' domain_delete_rejected_body: 'You have rejected pending domain deletion. You will receive confirmation by email.' no_permission: 'No permission'