-
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 #297 from shankari/sync_config
Add server support for the sync config
- Loading branch information
Showing
9 changed files
with
100 additions
and
5 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
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
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
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,8 @@ | ||
import logging | ||
import emission.analysis.configs.config_utils as eacc | ||
|
||
def get_config(user_id, time_query): | ||
# right now, we are not doing any server side overrides, so we pick the | ||
# last user defined configuration for this user | ||
SYNC_CONFIG_KEY = "config/sync_config" | ||
return eacc.get_last_entry(user_id, time_query, SYNC_CONFIG_KEY) |
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
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,13 @@ | ||
import logging | ||
import emission.core.wrapper.wrapperbase as ecwb | ||
|
||
class Syncconfig(ecwb.WrapperBase): | ||
props = {"sync_interval": ecwb.WrapperBase.Access.RO, # the interval at which data is synced and the battery level is read | ||
"ios_device_token": ecwb.WrapperBase.Access.RO} # device_token for ios, used for registering the device to the appropriate channel | ||
enums = {} | ||
geojson = [] | ||
nullable = [] | ||
local_dates = [] | ||
|
||
def _populateDependencies(self): | ||
pass |
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,29 @@ | ||
import logging | ||
import pytz | ||
import attrdict as ad | ||
import copy | ||
|
||
import emission.core.wrapper.syncconfig 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 = ad.AttrDict() | ||
|
||
metadata = entry.metadata | ||
try: | ||
valid_tz = pytz.timezone(entry.metadata.time_zone) | ||
except 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 copy | ||
|
||
import emission.core.wrapper.syncconfig 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 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