Skip to content

Commit

Permalink
Fix a bunch of issues with the initial data collection for ground truth
Browse files Browse the repository at this point in the history
- 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
shankari committed Apr 10, 2016
1 parent 832fbc7 commit 9623b2a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bin/historical/fix_ios_broken_battery.py
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})
25 changes: 25 additions & 0 deletions bin/historical/fix_sensor_config_key.py
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")

0 comments on commit 9623b2a

Please sign in to comment.