forked from e-mission/e-mission-server
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a bunch of issues with the initial data collection for ground truth
- In particular, the iOS battery level was never read, so we always got -100 - The android key was always "sensor_config" (because when we updated the read timestamp on the document, it updated everything including the key) e-mission/cordova-usercache#14
- Loading branch information
Showing
2 changed files
with
29 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,4 @@ | ||
import emission.core.get_database as edb | ||
|
||
edb.get_timeseries_db().remove({'metadata.key': 'background/battery', | ||
'data.battery_level_pct': -100}) |
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,25 @@ | ||
import emission.core.get_database as edb | ||
|
||
|
||
def fix_key(check_field, new_key): | ||
print "First entry for "+new_key+" is %s" % list(edb.get_timeseries_db().find( | ||
{"metadata.key": "config/sensor_config", | ||
check_field: {"$exists": True}}).sort( | ||
"metadata/write_ts").limit(1)) | ||
udb = edb.get_usercache_db() | ||
tdb = edb.get_timeseries_db() | ||
for i, entry in enumerate(edb.get_timeseries_db().find( | ||
{"metadata.key": "config/sensor_config", | ||
check_field: {"$exists": True}})): | ||
entry["metadata"]["key"] = new_key | ||
if i % 10000 == 0: | ||
print udb.insert(entry) | ||
print tdb.remove(entry["_id"]) | ||
else: | ||
udb.insert(entry) | ||
tdb.remove(entry["_id"]) | ||
|
||
fix_key("data.battery_status", "background/battery") | ||
fix_key("data.latitude", "background/location") | ||
fix_key("data.zzaEh", "background/motion_activity") | ||
fix_key("data.currState", "statemachine/transition") |