Browse files

Changing names to conform to business language

entry success -> content engagement

@pbadenski
@maxfliri
  • Loading branch information...
1 parent b64c0cd commit 98efb0855c0d8c4094119da0a2ab60ed161f2fec @maxfliri maxfliri committed Jan 22, 2013
Showing with 43 additions and 139 deletions.
  1. +3 −3 config/schedule.rb
  2. +3 −3 lib/collectors/{insidegov_weekly_entry_success.rb → insidegov_weekly_content_engagement.rb}
  3. +3 −3 lib/collectors/{weekly_entry_success.rb → weekly_content_engagement.rb}
  4. +3 −3 lib/collectors/{weekly_entry_success_transaction.rb → weekly_content_engagement_transaction.rb}
  5. +1 −1 lib/response/{weekly_entry_success_response.rb → weekly_content_engagement_response.rb}
  6. +0 −56 lib/response/weekly_transaction_response.rb
  7. +3 −3 lib/tasks/collect.rake
  8. 0 ...ly-entry-success-from-2012-12-09.json → insidegov-weekly-content-engagement-from-2012-12-09.json}
  9. 0 ...ly-entry-success-from-2012-12-16.json → insidegov-weekly-content-engagement-from-2012-12-16.json}
  10. 0 ...ly-entry-success-from-2012-12-23.json → insidegov-weekly-content-engagement-from-2012-12-23.json}
  11. 0 ...ures/{weekly-entry-success-from-2012-12-09.json → weekly-content-engagement-from-2012-12-09.json}
  12. 0 ...ures/{weekly-entry-success-from-2012-12-16.json → weekly-content-engagement-from-2012-12-16.json}
  13. 0 ...ures/{weekly-entry-success-from-2012-12-23.json → weekly-content-engagement-from-2012-12-23.json}
  14. 0 spec/fixtures/{weekly_entry_success_response.json → weekly_content_engagement_response.json}
  15. 0 ...ekly_entry_success_response_no_results.json → weekly_content_engagement_response_no_results.json}
  16. 0 ...ly_entry_success_response_year_switch.json → weekly_content_engagement_response_year_switch.json}
  17. +9 −9 spec/integration/insidegov_weekly_entry_success_spec.rb
  18. +9 −9 spec/integration/weekly_entry_success_spec.rb
  19. +2 −2 spec/integration/weekly_transaction_spec.rb
  20. +7 −7 ...nit/response/{weekly_entry_success_response_spec.rb → weekly_content_engagement_response_spec.rb}
  21. +0 −40 spec/unit/response/weekly_transaction_response_spec.rb
View
6 config/schedule.rb
@@ -9,12 +9,12 @@
every :sunday, :at => '5am' do
collector "broadcast", :config => "WeeklyVisits", :days_ago => 0
collector "broadcast", :config => "WeeklyVisitors", :days_ago => 0
- collector "broadcast", :config => "WeeklyEntrySuccess", :days_ago => 0
- collector "broadcast", :config => "WeeklyEntrySuccessTransaction", :days_ago => 0
+ collector "broadcast", :config => "WeeklyContentEngagement", :days_ago => 0
+ collector "broadcast", :config => "WeeklyContentEngagementTransaction", :days_ago => 0
collector "broadcast", :config => "InsideGovWeeklyVisitors", :days_ago => 0
collector "broadcast", :config => "InsideGovWeeklyPolicyEntries", :days_ago => 0
- collector "broadcast", :config => "InsideGovWeeklyEntrySuccess", :days_ago => 0
+ collector "broadcast", :config => "InsideGovWeeklyContentEngagement", :days_ago => 0
end
# Ten minutes after every full hour
View
6 ...lectors/insidegov_weekly_entry_success.rb → ...rs/insidegov_weekly_content_engagement.rb
@@ -1,10 +1,10 @@
require_relative "config/base"
require_relative "config/weekly_collector"
-require_relative "../../lib/response/weekly_entry_success_response"
+require_relative "../../lib/response/weekly_content_engagement_response"
module GoogleAnalytics
module Config
- class InsideGovWeeklyEntrySuccess < Base
+ class InsideGovWeeklyContentEngagement < Base
include WeeklyCollector
GOOGLE_ANALYTICS_URL_ID = "ga:53872948"
@@ -15,7 +15,7 @@ class InsideGovWeeklyEntrySuccess < Base
METRIC = "ga:totalEvents"
CATEGORY_PREFIX = 'IG_'
FILTERS= "ga:eventCategory=~^#{CATEGORY_PREFIX}.*"
- RESPONSE_TYPE = GoogleAnalytics::WeeklyEntrySuccessResponse
+ RESPONSE_TYPE = GoogleAnalytics::WeeklyContentEngagementResponse
end
end
end
View
6 lib/collectors/weekly_entry_success.rb → lib/collectors/weekly_content_engagement.rb
@@ -1,10 +1,10 @@
require_relative "config/base"
require_relative "config/weekly_collector"
-require_relative "../../lib/response/weekly_entry_success_response"
+require_relative "../../lib/response/weekly_content_engagement_response"
module GoogleAnalytics
module Config
- class WeeklyEntrySuccess < Base
+ class WeeklyContentEngagement < Base
include WeeklyCollector
GOOGLE_ANALYTICS_URL_ID = "ga:53872948"
@@ -15,7 +15,7 @@ class WeeklyEntrySuccess < Base
METRIC = "ga:totalEvents"
CATEGORY_PREFIX = 'MS_'
FILTERS= "ga:eventCategory=~^#{CATEGORY_PREFIX}.*"
- RESPONSE_TYPE = GoogleAnalytics::WeeklyEntrySuccessResponse
+ RESPONSE_TYPE = GoogleAnalytics::WeeklyContentEngagementResponse
end
end
end
View
6 ...ctors/weekly_entry_success_transaction.rb → .../weekly_content_engagement_transaction.rb
@@ -1,10 +1,10 @@
require_relative "config/base"
require_relative "config/weekly_collector"
-require_relative "../../lib/response/weekly_entry_success_response"
+require_relative "../../lib/response/weekly_content_engagement_response"
module GoogleAnalytics
module Config
- class WeeklyEntrySuccessTransaction < Base
+ class WeeklyContentEngagementTransaction < Base
include WeeklyCollector
GOOGLE_ANALYTICS_URL_ID = %w(ga:53872948 ga:61976178)
@@ -15,7 +15,7 @@ class WeeklyEntrySuccessTransaction < Base
METRIC = "ga:totalEvents"
CATEGORY_PREFIX = 'MS_'
FILTERS = "ga:eventCategory==MS_transaction"
- RESPONSE_TYPE = GoogleAnalytics::WeeklyEntrySuccessResponse
+ RESPONSE_TYPE = GoogleAnalytics::WeeklyContentEngagementResponse
def analytics_parameters()
self.class::GOOGLE_ANALYTICS_URL_ID.map do |id|
View
2 ...response/weekly_entry_success_response.rb → ...nse/weekly_content_engagement_response.rb
@@ -2,7 +2,7 @@
require_relative "extract_weekly_dates"
module GoogleAnalytics
- class WeeklyEntrySuccessResponse < BaseResponse
+ class WeeklyContentEngagementResponse < BaseResponse
include ExtractWeeklyDates
def initialize(response, config_class)
View
56 lib/response/weekly_transaction_response.rb
@@ -1,56 +0,0 @@
-require_relative "weekly_response"
-require_relative "extract_weekly_dates"
-
-module GoogleAnalytics
- class WeeklyTransactionResponse < BaseResponse
- include ExtractWeeklyDates
-
- def initialize(response, config_class)
- @site = config_class::SITE_KEY
- @config = config_class
- @messages = create_messages(response)
- end
-
- private
- ENTRY_LABEL = "Entry"
- SUCCESS_LABEL = "Success"
-
- def create_messages(response)
- rows = response.reduce([]) {|accumulator, item| accumulator + item["rows"] }
- messages = collect_by_format(rows).map do |(format, entries, successes)|
- create_message ({
- :start_at => extract_start_at(response.first["query"]["start-date"]),
- :end_at => extract_end_at(response.first["query"]["end-date"]),
- :value => {
- :site => @site,
- :format => normalize_format(format),
- :entries => entries,
- :successes => successes
- }
- })
- end
-
- messages
- end
-
- def collect_by_format rows
- weeks = {}
- rows.each do |(_, format, action, value)|
- weeks[format] ||= [0, 0]
- if action == ENTRY_LABEL
- weeks[format][0] += value.to_i
- elsif action == SUCCESS_LABEL
- weeks[format][1] += value.to_i
- else
- logger.warn { "Unrecognized action '#{action}' for format '#{format}'" }
- end
- end
- weeks.map(&:flatten)
- end
-
- def normalize_format format
- format.gsub(/^#{@config::CATEGORY_PREFIX}/, '')
- end
-
- end
-end
View
6 lib/tasks/collect.rake
@@ -7,11 +7,11 @@ collector_spec = [
{:config => 'DailyVisitors', :days_ago => 2},
{:config => 'WeeklyVisits', :days_ago => 200},
{:config => 'WeeklyVisitors', :days_ago => 200},
- {:config => 'WeeklyEntrySuccess', :days_ago => 100},
- {:config => 'WeeklyEntrySuccessTransaction', :days_ago => 100},
+ {:config => 'WeeklyContentEngagement', :days_ago => 100},
+ {:config => 'WeeklyContentEngagementTransaction', :days_ago => 100},
{:config => 'InsideGovWeeklyVisitors', :days_ago => 200},
{:config => 'InsideGovWeeklyPolicyEntries', :days_ago => 200},
- {:config => 'InsideGovWeeklyEntrySuccess', :days_ago => 200}
+ {:config => 'InsideGovWeeklyContentEngagement', :days_ago => 200}
]
namespace :collect do
View
0 ...weekly-entry-success-from-2012-12-09.json → ...y-content-engagement-from-2012-12-09.json
File renamed without changes.
View
0 ...weekly-entry-success-from-2012-12-16.json → ...y-content-engagement-from-2012-12-16.json
File renamed without changes.
View
0 ...weekly-entry-success-from-2012-12-23.json → ...y-content-engagement-from-2012-12-23.json
File renamed without changes.
View
0 ...weekly-entry-success-from-2012-12-09.json → ...y-content-engagement-from-2012-12-09.json
File renamed without changes.
View
0 ...weekly-entry-success-from-2012-12-16.json → ...y-content-engagement-from-2012-12-16.json
File renamed without changes.
View
0 ...weekly-entry-success-from-2012-12-23.json → ...y-content-engagement-from-2012-12-23.json
File renamed without changes.
View
0 ...xtures/weekly_entry_success_response.json → ...s/weekly_content_engagement_response.json
File renamed without changes.
View
0 ...ly_entry_success_response_no_results.json → ...ntent_engagement_response_no_results.json
File renamed without changes.
View
0 ...y_entry_success_response_year_switch.json → ...tent_engagement_response_year_switch.json
File renamed without changes.
View
18 spec/integration/insidegov_weekly_entry_success_spec.rb
@@ -1,6 +1,6 @@
require_relative "spec_helper"
-describe "Inside gov weekly entry success collector" do
+describe "Inside gov weekly content engagement collector" do
before(:each) do
stub_credentials
register_oauth_refresh
@@ -17,10 +17,10 @@
it "should query google analytics for specific dates" do
@ga_request.register(
"2012-12-23", "2012-12-29",
- "insidegov-weekly-entry-success-from-2012-12-23.json"
+ "insidegov-weekly-content-engagement-from-2012-12-23.json"
)
- configs = [GoogleAnalytics::Config::InsideGovWeeklyEntrySuccess.new(Date.new(2012, 12, 23), Date.new(2012, 12, 29))]
+ configs = [GoogleAnalytics::Config::InsideGovWeeklyContentEngagement.new(Date.new(2012, 12, 23), Date.new(2012, 12, 29))]
collector = GoogleAnalytics::Collector.new(nil, configs)
response = collector.collect_as_json
@@ -53,11 +53,11 @@
it "should query google analytics for last week today" do
@ga_request.register(
"2012-12-23", "2012-12-29",
- "insidegov-weekly-entry-success-from-2012-12-23.json"
+ "insidegov-weekly-content-engagement-from-2012-12-23.json"
)
Timecop.travel(DateTime.parse("2012-12-31")) do
- configs = GoogleAnalytics::Config::InsideGovWeeklyEntrySuccess.all_within(Date.today - 1, Date.today)
+ configs = GoogleAnalytics::Config::InsideGovWeeklyContentEngagement.all_within(Date.today - 1, Date.today)
collector = GoogleAnalytics::Collector.new(nil, configs)
response = collector.collect_as_json
@@ -78,18 +78,18 @@
it "should query google analytics for the previous three weeks" do
@ga_request.register(
"2012-12-09", "2012-12-15",
- "insidegov-weekly-entry-success-from-2012-12-09.json"
+ "insidegov-weekly-content-engagement-from-2012-12-09.json"
)
@ga_request.register(
"2012-12-16", "2012-12-22",
- "insidegov-weekly-entry-success-from-2012-12-16.json"
+ "insidegov-weekly-content-engagement-from-2012-12-16.json"
)
@ga_request.register(
"2012-12-23", "2012-12-29",
- "insidegov-weekly-entry-success-from-2012-12-23.json"
+ "insidegov-weekly-content-engagement-from-2012-12-23.json"
)
Timecop.travel(DateTime.parse("2012-12-31")) do
- configs = GoogleAnalytics::Config::InsideGovWeeklyEntrySuccess.all_within(
+ configs = GoogleAnalytics::Config::InsideGovWeeklyContentEngagement.all_within(
Date.new(2012, 12, 10),
Date.today
)
View
18 spec/integration/weekly_entry_success_spec.rb
@@ -1,6 +1,6 @@
require_relative "spec_helper"
-describe "Weekly entry success collector" do
+describe "Weekly content engagement collector" do
before(:each) do
stub_credentials
register_oauth_refresh
@@ -17,10 +17,10 @@
it "should query google analytics for specific dates" do
@ga_request.register(
"2012-12-23", "2012-12-29",
- "weekly-entry-success-from-2012-12-23.json"
+ "weekly-content-engagement-from-2012-12-23.json"
)
- collector = GoogleAnalytics::Collector.new(nil, [GoogleAnalytics::Config::WeeklyEntrySuccess.new(Date.new(2012, 12, 23), Date.new(2012, 12, 29))])
+ collector = GoogleAnalytics::Collector.new(nil, [GoogleAnalytics::Config::WeeklyContentEngagement.new(Date.new(2012, 12, 23), Date.new(2012, 12, 29))])
response = collector.collect_as_json
response.should have(5).item
@@ -52,11 +52,11 @@
it "should query google analytics for last week today" do
@ga_request.register(
"2012-12-23", "2012-12-29",
- "weekly-entry-success-from-2012-12-23.json"
+ "weekly-content-engagement-from-2012-12-23.json"
)
Timecop.travel(DateTime.parse("2012-12-31")) do
- collector = GoogleAnalytics::Collector.new(nil, GoogleAnalytics::Config::WeeklyEntrySuccess.all_within(Date.today - 1, Date.today))
+ collector = GoogleAnalytics::Collector.new(nil, GoogleAnalytics::Config::WeeklyContentEngagement.all_within(Date.today - 1, Date.today))
response = collector.collect_as_json
response.should have(5).item
@@ -76,18 +76,18 @@
it "should query google analytics for the previous three weeks" do
@ga_request.register(
"2012-12-09", "2012-12-15",
- "weekly-entry-success-from-2012-12-09.json"
+ "weekly-content-engagement-from-2012-12-09.json"
)
@ga_request.register(
"2012-12-16", "2012-12-22",
- "weekly-entry-success-from-2012-12-16.json"
+ "weekly-content-engagement-from-2012-12-16.json"
)
@ga_request.register(
"2012-12-23", "2012-12-29",
- "weekly-entry-success-from-2012-12-23.json"
+ "weekly-content-engagement-from-2012-12-23.json"
)
Timecop.travel(DateTime.parse("2012-12-31")) do
- configs = GoogleAnalytics::Config::WeeklyEntrySuccess.all_within(
+ configs = GoogleAnalytics::Config::WeeklyContentEngagement.all_within(
Date.new(2012, 12, 10),
Date.today
)
View
4 spec/integration/weekly_transaction_spec.rb
@@ -28,7 +28,7 @@
@ga_request_2.register("2012-12-30", "2013-01-05",
"weekly_transaction_response.json")
- collector = GoogleAnalytics::Collector.new(nil, [GoogleAnalytics::Config::WeeklyEntrySuccessTransaction.new(Date.new(2012, 12, 30), Date.new(2013, 01, 5))])
+ collector = GoogleAnalytics::Collector.new(nil, [GoogleAnalytics::Config::WeeklyContentEngagementTransaction.new(Date.new(2012, 12, 30), Date.new(2013, 01, 5))])
response = collector.collect_as_json
response.should have(1).item
@@ -60,7 +60,7 @@
"weekly_transaction_response__2012-12-09.json")
Timecop.travel(DateTime.parse("2012-12-31")) do
- configs = GoogleAnalytics::Config::WeeklyEntrySuccessTransaction.all_within(Date.new(2012,12,9),Date.today)
+ configs = GoogleAnalytics::Config::WeeklyContentEngagementTransaction.all_within(Date.new(2012,12,9),Date.today)
collector = GoogleAnalytics::Collector.new(nil, configs)
response = collector.collect_as_json
View
14 ...nse/weekly_entry_success_response_spec.rb → ...eekly_content_engagement_response_spec.rb
@@ -1,7 +1,7 @@
require_relative "../../spec_helper"
include GoogleAnalytics
-describe "weekly entry/success response" do
+describe "weekly content/engagement response" do
def message_for_format format
@response.messages.find do |msg|
@@ -12,8 +12,8 @@ def message_for_format format
describe "without year switch" do
before(:each) do
- response_as_hash = load_json("weekly_entry_success_response.json")
- @response = WeeklyEntrySuccessResponse.new([response_as_hash], GoogleAnalytics::Config::WeeklyEntrySuccess)
+ response_as_hash = load_json("weekly_content_engagement_response.json")
+ @response = WeeklyContentEngagementResponse.new([response_as_hash], GoogleAnalytics::Config::WeeklyContentEngagement)
end
it "should have an array of messages" do
@@ -52,8 +52,8 @@ def message_for_format format
describe "with year switch" do
before(:each) do
- response_as_hash = load_json("weekly_entry_success_response_year_switch.json")
- @response = WeeklyEntrySuccessResponse.new([response_as_hash], GoogleAnalytics::Config::WeeklyEntrySuccess)
+ response_as_hash = load_json("weekly_content_engagement_response_year_switch.json")
+ @response = WeeklyContentEngagementResponse.new([response_as_hash], GoogleAnalytics::Config::WeeklyContentEngagement)
end
it "should have an array of messages" do
@@ -91,8 +91,8 @@ def message_for_format format
describe "response with no results" do
before(:each) do
- response_as_hash = load_json("weekly_entry_success_response_no_results.json")
- @response = WeeklyEntrySuccessResponse.new([response_as_hash], GoogleAnalytics::Config::WeeklyEntrySuccess)
+ response_as_hash = load_json("weekly_content_engagement_response_no_results.json")
+ @response = WeeklyContentEngagementResponse.new([response_as_hash], GoogleAnalytics::Config::WeeklyContentEngagement)
end
it "should create no messages" do
View
40 spec/unit/response/weekly_transaction_response_spec.rb
@@ -1,40 +0,0 @@
-require_relative "../../spec_helper"
-
-describe "weekly entry/success response" do
-
- describe "when on a year boundary" do
- before(:each) do
- response_as_hash = load_json("weekly_transaction_response.json")
- @response = WeeklyTransactionResponse.new([response_as_hash], GoogleAnalytics::Config::WeeklyEntrySuccess)
- end
-
- it "should have an array of messages" do
- @response.messages.should be_an(Array)
- @response.messages.should have(1).message
- end
-
- it "should have an envelope and payload" do
- @response.messages.first[:envelope].should be_a(Hash)
- @response.messages.first[:envelope][:collected_at].should be_a(DateTime)
- @response.messages.first[:envelope][:collector].should == "Google Analytics"
- @response.messages.first[:payload].should be_a(Hash)
- end
-
- it "should have start at, end at and site data in the payload" do
- payload = @response.messages.first[:payload]
- payload[:start_at].should == "2012-12-30T00:00:00+00:00"
- payload[:end_at].should == "2013-01-06T00:00:00+00:00"
- payload[:value][:site].should == "govuk"
- end
-
- it "should have successes for transactions" do
- payload = @response.messages.first[:payload]
- payload[:value][:successes].should == 1431421
- end
-
- it "should have format set to transaction in payload" do
- @response.messages.first[:payload][:value][:format].should == "transaction"
- end
- end
-
-end

0 comments on commit 98efb08

Please sign in to comment.