Giter Site home page Giter Site logo

uoa-eresearch / fit_api Goto Github PK

View Code? Open in Web Editor NEW
19.0 13.0 2.0 100 KB

A web interface to gain consent from a user, to obtain their Google Fit data from the API, such that it can be resurfaced more easily via API

Home Page: https://app.swaggerhub.com/apis-docs/neon-ninja/fitapi/0.1

License: MIT License

HTML 1.78% Python 98.22%
python bottle google-fit google-fit-api google-api

fit_api's Issues

Code change request

main.py line 10 needs to update its code to import the right Google API client module:
from apiclient.discovery import build
Change to
from googleapiclient.discovery import build
Do you want me to create such pull request?

Deployment instructions Improvement: Python version

The README.md file does not say Python 2.x installs better than Python 3.x. With Python 3.x, the mysql-python package fails to install:

$ pip install mysql-python
Collecting mysql-python
Using cached https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-install-a8xpteof/mysql-python/setup.py", line 13, in
from setup_posix import get_config
File "/tmp/pip-install-a8xpteof/mysql-python/setup_posix.py", line 2, in
from ConfigParser import SafeConfigParser
ModuleNotFoundError: No module named 'ConfigParser'

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-a8xpteof/mysql-python/

Whereas, with Python 2.x, it installed fine:

$ python --version
Python 2.7.15rc1
$ pip install mysql-python
Collecting mysql-python
Using cached https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip
Building wheels for collected packages: mysql-python
Running setup.py bdist_wheel for mysql-python ... done
Stored in directory: /home/hil/.cache/pip/wheels/07/d2/5f/314860e4cb53a44bf0ee0d051d4b34465e4b4fbe9de6d42f42
Successfully built mysql-python
Installing collected packages: mysql-python
Successfully installed mysql-python-1.2.5

I can create a pull request to add instructions of Python version. Please tell me if you want me to.

Unused files: web.2.7.config, web.3.4.config, ptvs_virtualenv_proxy.py, config.py.example

  • I found that during my development, 3 file are unused: web.3.4.config, ptvs_virtualenv_proxy.py. The README.md did not mention them. Are they still required?

  • I created a pull request to replace config.py.example with a better solution. If that's merged. config.py.example won't be needed.

Please tell me which files you want to remove. I will remove them in my next pull request. You don't need to push changes.

from the merge request to adding more tests

  • I left a review comment in the pull request about a bug. If you think the pull request is good, please merge.
  • I verify the most basic scenario at @app.get('/'). In my next pull request, I will add more postman tests including testing your current features. Do you think tests will be valuable?

Pycharm Debugging constant timeout

If I launch main.py in Pycharm by hitting the debug button, the application times out after 10-20 seconds. I tried stopping at a debug point and no debug points. All situations in Debug times out. I can't figure out why.

/home/hil/mavenwave/fitness/bin/python /opt/pycharm-2017.2.3/helpers/pydev/pydevd.py --multiproc --qt-support=auto --client 127.0.0.1 --port 45235 --file /home/hil/mavenwave/fitness/fit_api/main.py --log-level=DEBUG
pydev debugger: process 27353 is connecting

Connected to pydev debugger (build 172.3968.37)
Bottle v0.12.16 server starting up (using GunicornServer(workers=8))...
Listening on http://0.0.0.0:8080/
Hit Ctrl-C to quit.

[2019-01-16 18:05:58 +0000] [27353] [DEBUG] Current configuration:
  proxy_protocol: False
  worker_connections: 1000
  disable_redirect_access_to_syslog: False
  statsd_host: None
  max_requests_jitter: 0
  post_fork: <function post_fork at 0x7fbe662fb9b0>
  errorlog: -
  enable_stdio_inheritance: False
  worker_class: sync
  ssl_version: 2
  suppress_ragged_eofs: True
  syslog_facility: user
  when_ready: <function when_ready at 0x7fbe662fb7d0>
  pre_fork: <function pre_fork at 0x7fbe662fb8c0>
  cert_reqs: 0
  preload_app: False
  keepalive: 2
  sendfile: None
  reuse_port: False
  worker_tmp_dir: None
  group: 1000
  umask: 0
  secure_scheme_headers: {'X-FORWARDED-PROTOCOL': 'ssl', 'X-FORWARDED-PROTO': 'https', 'X-FORWARDED-SSL': 'on'}
  workers: 8
  graceful_timeout: 30
  do_handshake_on_connect: False
  spew: False
  proc_name: None
  pre_exec: <function pre_exec at 0x7fbe662fbd70>
  limit_request_fields: 100
  pythonpath: None
  on_exit: <function on_exit at 0x7fbe6630c320>
  logconfig: None
  logconfig_dict: {}
  config: None
  pidfile: None
  check_config: False
  statsd_prefix: 
  on_reload: <function on_reload at 0x7fbe662fb6e0>
  reload_extra_files: []
  accesslog: None
  reload_engine: auto
  proxy_allow_ips: ['127.0.0.1']
  pre_request: <function pre_request at 0x7fbe662fbe60>
  post_request: <function post_request at 0x7fbe662fbed8>
  user: 1000
  forwarded_allow_ips: ['127.0.0.1']
  worker_int: <function worker_int at 0x7fbe662fbb90>
  paste: None
  raw_paste_global_conf: []
  threads: 1
  max_requests: 0
  limit_request_line: 4094
  access_log_format: %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"
  certfile: None
  on_starting: <function on_starting at 0x7fbe662fb5f0>
  post_worker_init: <function post_worker_init at 0x7fbe662fbaa0>
  worker_abort: <function worker_abort at 0x7fbe662fbc80>
  child_exit: <function child_exit at 0x7fbe6630c050>
  worker_exit: <function worker_exit at 0x7fbe6630c140>
  default_proc_name: gunicorn
  loglevel: DEBUG
  syslog: False
  syslog_prefix: None
  chdir: /home/hil/mavenwave/fitness/fit_api
  daemon: False
  syslog_addr: udp://localhost:514
  ciphers: TLSv1
  bind: ['0.0.0.0:8080']
  raw_env: []
  initgroups: False
  capture_output: False
  reload: False
  limit_request_field_size: 8190
  nworkers_changed: <function nworkers_changed at 0x7fbe6630c230>
  timeout: 30
  keyfile: None
  ca_certs: None
  tmp_upload_dir: None
  backlog: 2048
  logger_class: gunicorn.glogging.Logger
[2019-01-16 18:05:58 +0000] [27353] [INFO] Starting gunicorn 19.9.0
[2019-01-16 18:05:58 +0000] [27353] [DEBUG] Arbiter booted
[2019-01-16 18:05:58 +0000] [27353] [INFO] Listening at: http://0.0.0.0:8080 (27353)
[2019-01-16 18:05:58 +0000] [27353] [INFO] Using worker: sync
[2019-01-16 18:05:58 +0000] [27364] [INFO] Booting worker with pid: 27364
[2019-01-16 18:05:58 +0000] [27368] [INFO] Booting worker with pid: 27368
[2019-01-16 18:05:58 +0000] [27371] [INFO] Booting worker with pid: 27371
[2019-01-16 18:05:59 +0000] [27382] [INFO] Booting worker with pid: 27382
[2019-01-16 18:05:59 +0000] [27392] [INFO] Booting worker with pid: 27392
[2019-01-16 18:05:59 +0000] [27397] [INFO] Booting worker with pid: 27397
[2019-01-16 18:05:59 +0000] [27405] [INFO] Booting worker with pid: 27405
[2019-01-16 18:05:59 +0000] [27353] [DEBUG] 8 workers
[2019-01-16 18:05:59 +0000] [27413] [INFO] Booting worker with pid: 27413
[2019-01-16 18:06:10 +0000] [27405] [DEBUG] GET /
[2019-01-16 18:06:15 +0000] [27397] [DEBUG] GET /
('Inserted', {u'family_name': u'Liao', u'name': u'Hil Liao', u'picture': u'https://lh3.googleusercontent.com/-5Nunu5ItfqE/AAAAAAAAAAI/AAAAAAABbrY/K1NxkhDfAWk/photo.jpg', u'locale': u'en', u'gender': u'male', u'email': u'[email protected]', u'link': u'https://plus.google.com/+HilLiao', u'given_name': u'Hil', u'id': u'117869787603044385058', u'verified_email': True})
[email protected]
('Steps:', [['2018-12-17', 2240], ['2018-12-18', 3041], ['2018-12-19', 3683], ['2018-12-20', 2008], ['2018-12-21', 1388], ['2018-12-22', 4265], ['2018-12-23', 6833], ['2018-12-24', 3930], ['2018-12-25', 12054], ['2018-12-26', 3091], ['2018-12-27', 1758], ['2018-12-28', 2537], ['2018-12-29', 4462], ['2018-12-30', 2039], ['2018-12-31', 3739], ['2019-01-01', 7137], ['2019-01-02', 2210], ['2019-01-03', 987], ['2019-01-04', 1328], ['2019-01-05', 3055], ['2019-01-06', 3757], ['2019-01-07', 5694], ['2019-01-08', 3420], ['2019-01-09', 2328], ['2019-01-10', 5355], ['2019-01-11', 1440], ['2019-01-12', 2710], ['2019-01-13', 5437], ['2019-01-14', 1622], ['2019-01-15', 1977], ['2019-01-16', 774]])
('Activity:', [['2018-12-17', 3, 76116335, 18], ['2018-12-17', 0, 7139280, 4], ['2018-12-17', 7, 3114296, 23], ['2018-12-18', 3, 80046928, 17], ['2018-12-18', 7, 2947703, 15], ['2018-12-18', 0, 1947668, 3], ['2018-12-19', 3, 79499998, 18], ['2018-12-19', 7, 3357281, 19], ['2018-12-19', 0, 3183184, 3], ['2018-12-20', 3, 75078072, 14], ['2018-12-20', 0, 6236322, 4], ['2018-12-20', 7, 1714589, 12], ['2018-12-21', 3, 83887018, 12], ['2018-12-21', 7, 2391741, 11], ['2018-12-22', 3, 80636909, 18], ['2018-12-22', 7, 5041723, 22], ['2018-12-23', 3, 63222748, 23], ['2018-12-23', 0, 13579290, 8], ['2018-12-23', 7, 8736386, 24], ['2018-12-23', 8, 528544, 2], ['2018-12-24', 3, 67936650, 22], ['2018-12-24', 7, 8088351, 18], ['2018-12-24', 0, 6519598, 6], ['2018-12-24', 1, 443354, 1], ['2018-12-25', 3, 61998245, 12], ['2018-12-25', 35, 14736571, 1], ['2018-12-25', 0, 5085755, 2], ['2018-12-25', 7, 4457369, 12], ['2018-12-26', 3, 68840548, 15], ['2018-12-26', 0, 12179088, 6], ['2018-12-26', 7, 4972770, 19], ['2018-12-27', 3, 46474387, 3], ['2018-12-27', 7, 363153, 3], ['2018-12-28', 4, 0, 0], ['2018-12-29', 4, 0, 0], ['2018-12-30', 4, 0, 0], ['2018-12-31', 4, 0, 0], ['2019-01-01', 4, 0, 0], ['2019-01-02', 4, 0, 0], ['2019-01-03', 4, 0, 0], ['2019-01-04', 4, 0, 0], ['2019-01-05', 4, 0, 0], ['2019-01-06', 4, 0, 0], ['2019-01-07', 4, 0, 0], ['2019-01-08', 4, 0, 0], ['2019-01-09', 3, 33565080, 6], ['2019-01-09', 7, 1734946, 5], ['2019-01-10', 3, 72323221, 17], ['2019-01-10', 0, 6645890, 5], ['2019-01-10', 7, 5717680, 18], ['2019-01-11', 3, 80904920, 13], ['2019-01-11', 7, 2332540, 10], ['2019-01-11', 0, 1588274, 3], ['2019-01-12', 3, 75403884, 15], ['2019-01-12', 0, 5389836, 4], ['2019-01-12', 7, 3774927, 11], ['2019-01-12', 8, 81431, 1], ['2019-01-13', 3, 72854129, 17], ['2019-01-13', 7, 7686343, 18], ['2019-01-13', 0, 4771682, 4], ['2019-01-14', 3, 82140753, 18], ['2019-01-14', 7, 3316817, 18], ['2019-01-15', 3, 83298053, 11], ['2019-01-15', 7, 1830388, 14], ['2019-01-15', 0, 1271559, 3], ['2019-01-16', 3, 53232254, 10], ['2019-01-16', 0, 4513365, 3], ['2019-01-16', 7, 576517, 10]])
steps: 31 rows affected
activity: 68 rows affected
[2019-01-16 18:06:19 +0000] [27413] [DEBUG] GET /activity_for_user/[email protected]
[email protected]
{u'2018-12-19': 448, u'2018-12-18': 393, u'2018-12-31': 0, u'2018-12-30': 0, u'2018-12-17': 415, u'2019-01-14': 442, u'2019-01-15': 244, u'2019-01-16': 77, u'2019-01-10': 762, u'2019-01-11': 311, u'2019-01-12': 514, u'2019-01-13': 1025, u'2018-12-20': 229, u'2018-12-21': 319, u'2018-12-22': 672, u'2018-12-23': 1235, u'2018-12-24': 1138, u'2018-12-25': 2559, u'2018-12-26': 663, u'2018-12-27': 48, u'2018-12-28': 0, u'2018-12-29': 0, u'2019-01-03': 0, u'2019-01-02': 0, u'2019-01-01': 0, u'2019-01-07': 0, u'2019-01-06': 0, u'2019-01-05': 0, u'2019-01-04': 0, u'2019-01-09': 231, u'2019-01-08': 0}
[2019-01-16 18:06:26 +0000] [27397] [DEBUG] GET /activity_for_user/[email protected]
[email protected]
{u'2018-12-19': 448, u'2018-12-18': 393, u'2018-12-31': 0, u'2018-12-30': 0, u'2018-12-17': 415, u'2019-01-14': 442, u'2019-01-15': 244, u'2019-01-16': 77, u'2019-01-10': 762, u'2019-01-11': 311, u'2019-01-12': 514, u'2019-01-13': 1025, u'2018-12-20': 229, u'2018-12-21': 319, u'2018-12-22': 672, u'2018-12-23': 1235, u'2018-12-24': 1138, u'2018-12-25': 2559, u'2018-12-26': 663, u'2018-12-27': 48, u'2018-12-28': 0, u'2018-12-29': 0, u'2019-01-03': 0, u'2019-01-02': 0, u'2019-01-01': 0, u'2019-01-07': 0, u'2019-01-06': 0, u'2019-01-05': 0, u'2019-01-04': 0, u'2019-01-09': 231, u'2019-01-08': 0}
[2019-01-16 18:06:27 +0000] [27382] [DEBUG] GET /activity_for_user/[email protected]
[email protected]
{u'2018-12-19': 448, u'2018-12-18': 393, u'2018-12-31': 0, u'2018-12-30': 0, u'2018-12-17': 415, u'2019-01-14': 442, u'2019-01-15': 244, u'2019-01-16': 77, u'2019-01-10': 762, u'2019-01-11': 311, u'2019-01-12': 514, u'2019-01-13': 1025, u'2018-12-20': 229, u'2018-12-21': 319, u'2018-12-22': 672, u'2018-12-23': 1235, u'2018-12-24': 1138, u'2018-12-25': 2559, u'2018-12-26': 663, u'2018-12-27': 48, u'2018-12-28': 0, u'2018-12-29': 0, u'2019-01-03': 0, u'2019-01-02': 0, u'2019-01-01': 0, u'2019-01-07': 0, u'2019-01-06': 0, u'2019-01-05': 0, u'2019-01-04': 0, u'2019-01-09': 231, u'2019-01-08': 0}
[2019-01-16 18:06:28 +0000] [27405] [DEBUG] GET /favicon.ico
[2019-01-16 18:07:27 +0000] [27413] [DEBUG] GET /activity_for_user_details/[email protected]
[email protected]
{u'2018-12-19': {'minutes': 56, 'activity_type': u'Walking*'}, u'2018-12-18': {'minutes': 49, 'activity_type': u'Walking*'}, u'2018-12-31': {'minutes': 0, 'activity_type': u'Unknown (unable to detect activity)*'}, u'2018-12-30': {'minutes': 0, 'activity_type': u'Unknown (unable to detect activity)*'}, u'2018-12-17': {'minutes': 52, 'activity_type': u'Walking*'}, u'2019-01-14': {'minutes': 55, 'activity_type': u'Walking*'}, u'2019-01-15': {'minutes': 31, 'activity_type': u'Walking*'}, u'2019-01-16': {'minutes': 10, 'activity_type': u'Walking*'}, u'2019-01-10': {'minutes': 95, 'activity_type': u'Walking*'}, u'2019-01-11': {'minutes': 39, 'activity_type': u'Walking*'}, u'2019-01-12': {'minutes': 63, 'activity_type': u'Walking*'}, u'2019-01-13': {'minutes': 128, 'activity_type': u'Walking*'}, u'2018-12-20': {'minutes': 29, 'activity_type': u'Walking*'}, u'2018-12-21': {'minutes': 40, 'activity_type': u'Walking*'}, u'2018-12-22': {'minutes': 84, 'activity_type': u'Walking*'}, u'2018-12-23': {'minutes': 146, 'activity_type': u'Walking*'}, u'2018-12-24': {'minutes': 135, 'activity_type': u'Walking*'}, u'2018-12-25': {'minutes': 74, 'activity_type': u'Walking*'}, u'2018-12-26': {'minutes': 83, 'activity_type': u'Walking*'}, u'2018-12-27': {'minutes': 6, 'activity_type': u'Walking*'}, u'2018-12-28': {'minutes': 0, 'activity_type': u'Unknown (unable to detect activity)*'}, u'2018-12-29': {'minutes': 0, 'activity_type': u'Unknown (unable to detect activity)*'}, u'2019-01-03': {'minutes': 0, 'activity_type': u'Unknown (unable to detect activity)*'}, u'2019-01-02': {'minutes': 0, 'activity_type': u'Unknown (unable to detect activity)*'}, u'2019-01-01': {'minutes': 0, 'activity_type': u'Unknown (unable to detect activity)*'}, u'2019-01-07': {'minutes': 0, 'activity_type': u'Unknown (unable to detect activity)*'}, u'2019-01-06': {'minutes': 0, 'activity_type': u'Unknown (unable to detect activity)*'}, u'2019-01-05': {'minutes': 0, 'activity_type': u'Unknown (unable to detect activity)*'}, u'2019-01-04': {'minutes': 0, 'activity_type': u'Unknown (unable to detect activity)*'}, u'2019-01-09': {'minutes': 29, 'activity_type': u'Walking*'}, u'2019-01-08': {'minutes': 0, 'activity_type': u'Unknown (unable to detect activity)*'}}
[2019-01-16 18:07:58 +0000] [27353] [CRITICAL] WORKER TIMEOUT (pid:27382)
[2019-01-16 18:07:58 +0000] [27382] [INFO] Worker exiting (pid: 27382)
[2019-01-16 18:07:58 +0000] [27544] [INFO] Booting worker with pid: 27544
[2019-01-16 18:07:58 +0000] [27353] [INFO] Handling signal: int
[2019-01-16 18:07:58 +0000] [27364] [INFO] Worker exiting (pid: 27364)
[2019-01-16 18:07:58 +0000] [27368] [INFO] Worker exiting (pid: 27368)
[2019-01-16 18:07:58 +0000] [27371] [INFO] Worker exiting (pid: 27371)
[2019-01-16 18:07:58 +0000] [27405] [INFO] Worker exiting (pid: 27405)
[2019-01-16 18:07:58 +0000] [27413] [INFO] Worker exiting (pid: 27413)
[2019-01-16 18:07:58 +0000] [27397] [INFO] Worker exiting (pid: 27397)
[2019-01-16 18:07:58 +0000] [27392] [INFO] Worker exiting (pid: 27392)
[2019-01-16 18:07:58 +0000] [27544] [INFO] Worker exiting (pid: 27544)
[2019-01-16 18:07:59 +0000] [27353] [INFO] Shutting down: Master

Process finished with exit code 0

Deployment instructions Improvement: Need SQL script to create database, tables

The following SQL script is required to execute the program:

CREATE DATABASE fit;
create schema fit collate latin1_swedish_ci;

create table activity
(
	username varchar(50) null,
	day varchar(20) null,
	activity_type int null,
	length_ms int null,
	n_segments int null
);

create table activity_types
(
	name varchar(200) null,
	id int null
);

create table google_fit
(
	username varchar(50) null,
	google_id varchar(200) null,
	full_name varchar(50) charset utf8 null,
	gender varchar(10) null,
	image_url varchar(200) null,
	email varchar(50) null,
	refresh_token varchar(200) null
);

create table steps
(
	username varchar(50) null,
	steps int null,
	day varchar(20) null,
	minutes int null,
	activity_type varchar(50) null
);

Do you want me to add the script above to create.sql in a pull request?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.