-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #444 from shankari/move_stats_to_timeseries
Add formatters for the client stats
- Loading branch information
Showing
7 changed files
with
182 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import logging | ||
import copy | ||
import pytz | ||
|
||
import emission.core.wrapper.consentconfig as ecws | ||
import emission.net.usercache.formatters.common as fc | ||
|
||
# Currently, we just reflect this back to the user, so not much editing to do | ||
# here. Since we get the timezone from javascript guessing, though, let's just | ||
# verify that it is correct. | ||
def format(entry): | ||
formatted_entry = entry | ||
|
||
metadata = entry.metadata | ||
try: | ||
valid_tz = pytz.timezone(entry.metadata.time_zone) | ||
except pytz.UnknownTimeZoneError, e: | ||
logging.warn("Got error %s while checking format validity" % e) | ||
# Default timezone in for the Bay Area, which is probably a fairly safe | ||
# assumption for now | ||
metadata.time_zone = "America/Los_Angeles" | ||
# adds the python datetime and fmt_time entries. important for future searches! | ||
fc.expand_metadata_times(metadata) | ||
formatted_entry.metadata = metadata | ||
formatted_entry.data = entry.data | ||
return formatted_entry; |
26 changes: 26 additions & 0 deletions
26
emission/net/usercache/formatters/android/client_nav_event.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import logging | ||
import copy | ||
import pytz | ||
|
||
import emission.core.wrapper.consentconfig as ecws | ||
import emission.net.usercache.formatters.common as fc | ||
|
||
# Currently, we just reflect this back to the user, so not much editing to do | ||
# here. Since we get the timezone from javascript guessing, though, let's just | ||
# verify that it is correct. | ||
def format(entry): | ||
formatted_entry = entry | ||
|
||
metadata = entry.metadata | ||
try: | ||
valid_tz = pytz.timezone(entry.metadata.time_zone) | ||
except pytz.UnknownTimeZoneError, e: | ||
logging.warn("Got error %s while checking format validity" % e) | ||
# Default timezone in for the Bay Area, which is probably a fairly safe | ||
# assumption for now | ||
metadata.time_zone = "America/Los_Angeles" | ||
# adds the python datetime and fmt_time entries. important for future searches! | ||
fc.expand_metadata_times(metadata) | ||
formatted_entry.metadata = metadata | ||
formatted_entry.data = entry.data | ||
return formatted_entry; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import logging | ||
import copy | ||
import pytz | ||
|
||
import emission.core.wrapper.consentconfig as ecws | ||
import emission.net.usercache.formatters.common as fc | ||
|
||
# Currently, we just reflect this back to the user, so not much editing to do | ||
# here. Since we get the timezone from javascript guessing, though, let's just | ||
# verify that it is correct. | ||
def format(entry): | ||
formatted_entry = entry | ||
|
||
metadata = entry.metadata | ||
try: | ||
valid_tz = pytz.timezone(entry.metadata.time_zone) | ||
except pytz.UnknownTimeZoneError, e: | ||
logging.warn("Got error %s while checking format validity" % e) | ||
# Default timezone in for the Bay Area, which is probably a fairly safe | ||
# assumption for now | ||
metadata.time_zone = "America/Los_Angeles" | ||
# adds the python datetime and fmt_time entries. important for future searches! | ||
fc.expand_metadata_times(metadata) | ||
formatted_entry.metadata = metadata | ||
formatted_entry.data = entry.data | ||
return formatted_entry; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import logging | ||
import copy | ||
import pytz | ||
|
||
import emission.core.wrapper.consentconfig as ecws | ||
import emission.net.usercache.formatters.common as fc | ||
|
||
# Currently, we just reflect this back to the user, so not much editing to do | ||
# here. Since we get the timezone from javascript guessing, though, let's just | ||
# verify that it is correct. | ||
def format(entry): | ||
formatted_entry = entry | ||
|
||
metadata = entry.metadata | ||
try: | ||
valid_tz = pytz.timezone(entry.metadata.time_zone) | ||
except pytz.UnknownTimeZoneError, e: | ||
logging.warn("Got error %s while checking format validity" % e) | ||
# Default timezone in for the Bay Area, which is probably a fairly safe | ||
# assumption for now | ||
metadata.time_zone = "America/Los_Angeles" | ||
# adds the python datetime and fmt_time entries. important for future searches! | ||
fc.expand_metadata_times(metadata) | ||
formatted_entry.metadata = metadata | ||
formatted_entry.data = entry.data | ||
return formatted_entry; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import logging | ||
import copy | ||
import pytz | ||
|
||
import emission.core.wrapper.consentconfig as ecws | ||
import emission.net.usercache.formatters.common as fc | ||
|
||
# Currently, we just reflect this back to the user, so not much editing to do | ||
# here. Since we get the timezone from javascript guessing, though, let's just | ||
# verify that it is correct. | ||
def format(entry): | ||
formatted_entry = entry | ||
|
||
metadata = entry.metadata | ||
try: | ||
valid_tz = pytz.timezone(entry.metadata.time_zone) | ||
except pytz.UnknownTimeZoneError, e: | ||
logging.warn("Got error %s while checking format validity" % e) | ||
# Default timezone in for the Bay Area, which is probably a fairly safe | ||
# assumption for now | ||
metadata.time_zone = "America/Los_Angeles" | ||
# adds the python datetime and fmt_time entries. important for future searches! | ||
fc.expand_metadata_times(metadata) | ||
formatted_entry.metadata = metadata | ||
formatted_entry.data = entry.data | ||
return formatted_entry; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import logging | ||
import copy | ||
import pytz | ||
|
||
import emission.core.wrapper.consentconfig as ecws | ||
import emission.net.usercache.formatters.common as fc | ||
|
||
# Currently, we just reflect this back to the user, so not much editing to do | ||
# here. Since we get the timezone from javascript guessing, though, let's just | ||
# verify that it is correct. | ||
def format(entry): | ||
formatted_entry = entry | ||
|
||
metadata = entry.metadata | ||
try: | ||
valid_tz = pytz.timezone(entry.metadata.time_zone) | ||
except pytz.UnknownTimeZoneError, e: | ||
logging.warn("Got error %s while checking format validity" % e) | ||
# Default timezone in for the Bay Area, which is probably a fairly safe | ||
# assumption for now | ||
metadata.time_zone = "America/Los_Angeles" | ||
# adds the python datetime and fmt_time entries. important for future searches! | ||
fc.expand_metadata_times(metadata) | ||
formatted_entry.metadata = metadata | ||
formatted_entry.data = entry.data | ||
return formatted_entry; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import logging | ||
import copy | ||
import pytz | ||
|
||
import emission.core.wrapper.consentconfig as ecws | ||
import emission.net.usercache.formatters.common as fc | ||
|
||
# Currently, we just reflect this back to the user, so not much editing to do | ||
# here. Since we get the timezone from javascript guessing, though, let's just | ||
# verify that it is correct. | ||
def format(entry): | ||
formatted_entry = entry | ||
|
||
metadata = entry.metadata | ||
try: | ||
valid_tz = pytz.timezone(entry.metadata.time_zone) | ||
except pytz.UnknownTimeZoneError, e: | ||
logging.warn("Got error %s while checking format validity" % e) | ||
# Default timezone in for the Bay Area, which is probably a fairly safe | ||
# assumption for now | ||
metadata.time_zone = "America/Los_Angeles" | ||
# adds the python datetime and fmt_time entries. important for future searches! | ||
fc.expand_metadata_times(metadata) | ||
formatted_entry.metadata = metadata | ||
formatted_entry.data = entry.data | ||
return formatted_entry; |