Skip to content

Instantly share code, notes, and snippets.

@mwilliams
Created April 23, 2018 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwilliams/db470985c2f7121a260742f52b0bb29f to your computer and use it in GitHub Desktop.
Save mwilliams/db470985c2f7121a260742f52b0bb29f to your computer and use it in GitHub Desktop.
URL = '<nightscout url>/api/v1/entries.json'.freeze
def index
response = JSON.parse(HTTParty.get(URL).body)
chart_data = response.map {|r| r["glucose"].to_i}
payload = {
"frames": [
{
"text": response[0]['glucose'].to_s,
"icon": 'i20045', # Blue circle logo
"index": 0 # Latest glucose reading
},
{
"index": 1, # Sparkline
"chartData": chart_data.reverse
}
]
}
render json: payload
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment