initial
This commit is contained in:
parent
9795c058fb
commit
1486266bb3
2 changed files with 53 additions and 5 deletions
10
TODO.org
10
TODO.org
|
@ -6,10 +6,10 @@ https://github.com/oshev/colifer/blob/592cc6b4d1ac9005c52fccdfb4e207513812baaa/c
|
||||||
https://github.com/oshev/colifer/blob/592cc6b4d1ac9005c52fccdfb4e207513812baaa/reportextenders/jawbone/jawbone_sleep.py
|
https://github.com/oshev/colifer/blob/592cc6b4d1ac9005c52fccdfb4e207513812baaa/reportextenders/jawbone/jawbone_sleep.py
|
||||||
https://github.com/GlenCrawford/ruby_jawbone
|
https://github.com/GlenCrawford/ruby_jawbone
|
||||||
|
|
||||||
* TODO extract sleep intervals
|
|
||||||
https://jawbone.com/up/developer/endpoints/sleeps
|
|
||||||
sleep phases here
|
|
||||||
|
|
||||||
|
|
||||||
* https://nyquist212.wordpress.com/2015/06/22/visualizing-jawbone-up-data-with-d3-js/
|
* https://nyquist212.wordpress.com/2015/06/22/visualizing-jawbone-up-data-with-d3-js/
|
||||||
|
|
||||||
|
|
||||||
|
* jawbone sleeps meta:
|
||||||
|
** time_created: apparently starto of sleep (leftmost point of plot)
|
||||||
|
** time_updated: rightmost point of plot
|
||||||
|
** details -> asleep_time, awake_time
|
||||||
|
|
48
analyse.py
Executable file
48
analyse.py
Executable file
|
@ -0,0 +1,48 @@
|
||||||
|
#!/usr/bin/env python3.6
|
||||||
|
from kython import *
|
||||||
|
|
||||||
|
from backup_config import SLEEPS_FILE
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
|
from datetime import date
|
||||||
|
|
||||||
|
XID = str # TODO how to shared with backup thing?
|
||||||
|
|
||||||
|
class SleepEntry:
|
||||||
|
def __init__(self, js) -> None:
|
||||||
|
self.js = js
|
||||||
|
|
||||||
|
# TODO @memoize decorator?
|
||||||
|
def date_(self) -> date:
|
||||||
|
dates = str(self.js['date'])
|
||||||
|
return datetime.strptime(dates, "%Y%m%d").date()
|
||||||
|
|
||||||
|
def title(self) -> str:
|
||||||
|
return self.js['title']
|
||||||
|
|
||||||
|
def xid(self) -> XID:
|
||||||
|
return self.js['xid']
|
||||||
|
|
||||||
|
def _details(self):
|
||||||
|
return self.js['details']
|
||||||
|
|
||||||
|
# TODO take timezones into account?
|
||||||
|
def created(self) -> datetime:
|
||||||
|
return datetime.fromtimestamp(self.js['time_created'])
|
||||||
|
|
||||||
|
def completed(self) -> datetime:
|
||||||
|
return datetime.fromtimestamp(self.js['time_completed'])
|
||||||
|
|
||||||
|
def __str__(self) -> str:
|
||||||
|
return f"{self.date_()} {self.title()}"
|
||||||
|
|
||||||
|
def __repr__(self) -> str:
|
||||||
|
return str(self)
|
||||||
|
|
||||||
|
def load_sleeps() -> List[SleepEntry]:
|
||||||
|
with open(SLEEPS_FILE, 'r') as fo:
|
||||||
|
sleeps = json_load(fo)
|
||||||
|
return [SleepEntry(js) for js in sleeps]
|
||||||
|
|
||||||
|
sleeps = load_sleeps()
|
||||||
|
pprint(sleeps[:2])
|
Loading…
Add table
Reference in a new issue