-
{{i18n admin.logs.screened_urls.url}}
+
{{i18n admin.logs.screened_urls.domain}}
{{i18n admin.logs.action}}
{{i18n admin.logs.match_count}}
{{i18n admin.logs.last_match_at}}
{{i18n admin.logs.created_at}}
-
{{i18n admin.logs.ip_address}}
diff --git a/app/assets/javascripts/admin/templates/logs/screened_urls_list_item.js.handlebars b/app/assets/javascripts/admin/templates/logs/screened_urls_list_item.js.handlebars
index c122fc073bc..69cb12c4d2d 100644
--- a/app/assets/javascripts/admin/templates/logs/screened_urls_list_item.js.handlebars
+++ b/app/assets/javascripts/admin/templates/logs/screened_urls_list_item.js.handlebars
@@ -1,9 +1,8 @@
-
-
{{url}}
+
{{actionName}}
{{match_count}}
{{unboundAgeWithTooltip last_match_at}}
{{unboundAgeWithTooltip created_at}}
-
{{ip_address}}
\ No newline at end of file
diff --git a/app/assets/stylesheets/common/admin/admin_base.scss b/app/assets/stylesheets/common/admin/admin_base.scss
index 12fed2b0231..00011878588 100644
--- a/app/assets/stylesheets/common/admin/admin_base.scss
+++ b/app/assets/stylesheets/common/admin/admin_base.scss
@@ -756,7 +756,7 @@ table.api-keys {
}
.screened-emails, .screened-urls, .screened-ip-addresses {
- .email, .url {
+ .email, .url, .domain {
width: 300px;
}
.action, .match_count, .last_match_at, .created_at {
diff --git a/app/controllers/admin/screened_urls_controller.rb b/app/controllers/admin/screened_urls_controller.rb
index cc605e97aa9..0bb114af9fe 100644
--- a/app/controllers/admin/screened_urls_controller.rb
+++ b/app/controllers/admin/screened_urls_controller.rb
@@ -1,8 +1,8 @@
class Admin::ScreenedUrlsController < Admin::AdminController
def index
- screened_urls = ScreenedUrl.limit(200).order('last_match_at desc').to_a
- render_serialized(screened_urls, ScreenedUrlSerializer)
+ screened_urls = ScreenedUrl.select("domain, sum(match_count) as match_count, max(last_match_at) as last_match_at, min(created_at) as created_at").group(:domain).to_a
+ render_serialized(screened_urls, GroupedScreenedUrlSerializer)
end
end
diff --git a/app/models/screened_url.rb b/app/models/screened_url.rb
index 5da8d044799..5f54a9ecb61 100644
--- a/app/models/screened_url.rb
+++ b/app/models/screened_url.rb
@@ -18,7 +18,7 @@ class ScreenedUrl < ActiveRecord::Base
def normalize
self.url = ScreenedUrl.normalize_url(self.url) if self.url
- self.domain = self.domain.downcase if self.domain
+ self.domain = self.domain.downcase.sub(/^www\./, '') if self.domain
end
def self.watch(url, domain, opts={})
diff --git a/app/serializers/grouped_screened_url_serializer.rb b/app/serializers/grouped_screened_url_serializer.rb
new file mode 100644
index 00000000000..c57bb8c30a9
--- /dev/null
+++ b/app/serializers/grouped_screened_url_serializer.rb
@@ -0,0 +1,11 @@
+class GroupedScreenedUrlSerializer < ApplicationSerializer
+ attributes :domain,
+ :action,
+ :match_count,
+ :last_match_at,
+ :created_at
+
+ def action
+ 'do_nothing'
+ end
+end
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 619cf683100..b40d6f1187b 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -1270,6 +1270,7 @@ en:
title: "Screened URLs"
description: "The URLs listed here were used in posts by users who have been identified as spammers."
url: "URL"
+ domain: "Domain"
screened_ips:
title: "Screened IPs"
description: 'IP addresses that are being watched. Use "Allow" to whitelist IP addresses.'
diff --git a/spec/models/screened_url_spec.rb b/spec/models/screened_url_spec.rb
index 2a099494f5d..33d435e6882 100644
--- a/spec/models/screened_url_spec.rb
+++ b/spec/models/screened_url_spec.rb
@@ -58,6 +58,20 @@ describe ScreenedUrl do
record2.should be_valid
end
+ it "strips www. from domains" do
+ record1 = described_class.new(valid_params.merge(domain: 'www.DuB30.com', url: 'www.DuB30.com/Gems/Gems-of-Power'))
+ record1.normalize
+ record1.domain.should == 'dub30.com'
+
+ record2 = described_class.new(valid_params.merge(domain: 'WWW.DuB30.cOM', url: 'WWW.DuB30.com/Gems/Gems-of-Power'))
+ record2.normalize
+ record2.domain.should == 'dub30.com'
+
+ record3 = described_class.new(valid_params.merge(domain: 'www.trolls.spammers.com', url: 'WWW.DuB30.com/Gems/Gems-of-Power'))
+ record3.normalize
+ record3.domain.should == 'trolls.spammers.com'
+ end
+
it "doesn't modify the url argument" do
expect {
described_class.new(valid_params).normalize