Skip to content

Commit

Permalink
Fix timezone handling in public metrics page.
Browse files Browse the repository at this point in the history
  • Loading branch information
GUI committed Jun 15, 2017
1 parent 3187452 commit 137afa6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Expand Up @@ -52,7 +52,7 @@ def generate_summary
:hits_by_month => [],
}

start_time = Time.parse("2013-07-01").utc
start_time = Time.utc(2013, 7, 1)

# Fetch the user signups by month, trying to remove duplicate signups for
# the same e-mail address (each e-mail address only gets counted for the first
Expand Down
14 changes: 7 additions & 7 deletions test/apis/v0/test_analytics.rb
Expand Up @@ -7,7 +7,7 @@ def setup
super
setup_server
ApiUser.where(:registration_source.ne => "seed").delete_all
ElasticsearchHelper.clean_es_indices(["2013-06", "2013-07"])
ElasticsearchHelper.clean_es_indices(["2013-07", "2013-08"])

@db = Mongoid.client(:default)
@db[:rails_cache].delete_many
Expand All @@ -28,8 +28,8 @@ def test_allows_api_key_with_role
end

def test_expected_response
FactoryGirl.create_list(:api_user, 3, :created_at => Time.parse("2013-07-15T00:00:00Z").utc)
FactoryGirl.create_list(:log_item, 2, :request_at => Time.parse("2013-07-15T00:00:00Z").utc)
FactoryGirl.create_list(:api_user, 3, :created_at => Time.parse("2013-08-15T00:00:00Z").utc)
FactoryGirl.create_list(:log_item, 2, :request_at => Time.parse("2013-08-15T00:00:00Z").utc)
LogItem.gateway.refresh_index!

response = make_request
Expand All @@ -44,23 +44,23 @@ def test_expected_response

assert_equal({
"year" => 2013,
"month" => 6,
"month" => 7,
"count" => 0,
}, data["hits_by_month"][0])
assert_equal({
"year" => 2013,
"month" => 7,
"month" => 8,
"count" => 2,
}, data["hits_by_month"][1])

assert_equal({
"year" => 2013,
"month" => 6,
"month" => 7,
"count" => 0,
}, data["users_by_month"][0])
assert_equal({
"year" => 2013,
"month" => 7,
"month" => 8,
"count" => 3,
}, data["users_by_month"][1])
end
Expand Down
2 changes: 1 addition & 1 deletion test/support/api_umbrella_test_helpers/setup.rb
Expand Up @@ -68,7 +68,7 @@ def setup_server

# For simplicity sake, we're assuming our tests only deal with a few explicit
# indexes currently.
["2013-06", "2013-07", "2014-11", "2015-01", "2015-03"].each do |month|
["2013-07", "2013-08", "2014-11", "2015-01", "2015-03"].each do |month|
# First delete any existing indexes.
["api-umbrella-logs-v1-#{month}", "api-umbrella-logs-#{month}", "api-umbrella-logs-write-#{month}"].each do |index_name|
begin
Expand Down

0 comments on commit 137afa6

Please sign in to comment.