From dbe2eeb00d812b69343b37288719e57d068f7f9b Mon Sep 17 00:00:00 2001 From: evazion Date: Fri, 1 Jan 2021 22:46:46 -0600 Subject: [PATCH] emails: remove "Valid?" search option. No longer necessary after running previous commit because all invalid email addresses have been purged. --- app/logical/email_validator.rb | 1 - app/models/email_address.rb | 11 ----------- app/views/emails/index.html.erb | 6 ------ 3 files changed, 18 deletions(-) diff --git a/app/logical/email_validator.rb b/app/logical/email_validator.rb index be9951810..6e4b60194 100644 --- a/app/logical/email_validator.rb +++ b/app/logical/email_validator.rb @@ -5,7 +5,6 @@ module EmailValidator # https://www.regular-expressions.info/email.html EMAIL_REGEX = /\A[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}\z/ - POSTGRES_EMAIL_REGEX = "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}" IGNORE_DOTS = %w[gmail.com] IGNORE_PLUS_ADDRESSING = %w[gmail.com hotmail.com outlook.com live.com] diff --git a/app/models/email_address.rb b/app/models/email_address.rb index b43f0a6b4..f0420a734 100644 --- a/app/models/email_address.rb +++ b/app/models/email_address.rb @@ -45,21 +45,10 @@ class EmailAddress < ApplicationRecord end end - def self.valid(valid = true) - if valid.to_s.truthy? - where_regex(:address, EmailValidator::POSTGRES_EMAIL_REGEX.to_s) - elsif valid.to_s.falsy? - where_not_regex(:address, EmailValidator::POSTGRES_EMAIL_REGEX.to_s) - else - all - end - end - def self.search(params) q = search_attributes(params, :id, :created_at, :updated_at, :user, :address, :normalized_address, :is_verified, :is_deliverable) q = q.restricted(params[:is_restricted]) - q = q.valid(params[:is_valid]) q = q.apply_default_order(params) q diff --git a/app/views/emails/index.html.erb b/app/views/emails/index.html.erb index b03490a0a..8fc580d14 100644 --- a/app/views/emails/index.html.erb +++ b/app/views/emails/index.html.erb @@ -7,7 +7,6 @@ <%= f.input :address_ilike, label: "Address", input_html: { value: params[:search][:address_ilike] }, hint: "Use * for wildcard" %> <%= f.input :normalized_address_ilike, label: "Normalized Address", input_html: { value: params[:search][:normalized_address_ilike] }, hint: "Use * for wildcard" %> - <%= f.input :is_valid, label: "Valid?", as: :select, include_blank: true, selected: params[:search][:is_valid] %> <%= f.input :is_verified, label: "Verified?", as: :select, include_blank: true, selected: params[:search][:is_verified] %> <%= f.input :is_restricted, label: "Restricted?", as: :select, include_blank: true, selected: params[:search][:is_restricted] %> <%= f.submit "Search" %> @@ -25,11 +24,6 @@ <%= link_to email.normalized_address, emails_path(search: { normalized_address_ilike: email.normalized_address }) %> <% end %> <% end %> - <% t.column "Valid?" do |email| %> - <% if !email.is_valid? %> - <%= link_to "No", emails_path(search: { is_valid: false }) %> - <% end %> - <% end %> <% t.column "Restricted?" do |email| %> <% if email.is_restricted? %> <%= link_to "Yes", emails_path(search: { is_restricted: true }) %>