Is there an alternative to receiving activity data that isn't aggregated from Google Fit's REST API? - google-api

I am trying to get specific data that relates to individual activities.
I can retrieve all data relating to all activities that were performed within a time frame (day).
However it is not specific as to which dataset belongs to which activity i.e. there is no identifier.
It does not come back in order either.
I tried grouping by 'StartTimeNanos' but that is not a solid solution as the data is in random order too.
Is there an alternative way to get back activity specific data?
I completed the following activities:
Google fit walk activity
Google fit run activity
and after making the following http GET request to : https://fitness.googleapis.com/fitness/v1/users/me/dataSources.
It returns all datatSources for user {me} : as 'source'.
I then use all sources mapped to the objects:
{ "dataTypeName": "source.dataTypeName", "dataSourceId": "source.dataSourceId" }
I then pass it in the body of the call to: https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate
and the response is the following (with deleted values for readability here) :
{
"bucket": [
{
"startTimeMillis": "1673136000000",
"endTimeMillis": "1673215200000",
"dataset": [
{
"dataSourceId": "derived:com.google.active_minutes:com.google.android.gms:aggregated",
"point": [
{
"startTimeNanos": "1673176860000000000",
"endTimeNanos": "1673200740000000000",
"dataTypeName": "com.google.active_minutes",
"originDataSourceId": "derived:com.google.step_count.delta:com.google.android.gms:estimated_steps",
"value": [
{
"intVal": 103,
"mapVal": []
}
]
}
]
},
{
"dataSourceId": "derived:com.google.activity.summary:com.google.android.gms:aggregated",
"point": [
{
"startTimeNanos": "1673176862610000000",
"endTimeNanos": "1673181480270000000",
"dataTypeName": "com.google.activity.summary",
"originDataSourceId": "raw:com.google.activity.segment:nl.appyhapps.healthsync:running",
"value": [
{
"intVal": 8,
"mapVal": []
},
{
"intVal": 4564870,
"mapVal": []
},
{
"intVal": 2,
"mapVal": []
}
]
},
{
"startTimeNanos": "1673199914195000000",
"endTimeNanos": "1673200789933000000",
"dataTypeName": "com.google.activity.summary",
"originDataSourceId": "derived:com.google.activity.segment:nl.appyhapps.healthsync:session_activity_segment",
"value": [
{
"intVal": 7,
"mapVal": []
},
{
"intVal": 875738,
"mapVal": []
},
{
"intVal": 1,
"mapVal": []
}
]
}
]
},
{
"dataSourceId": "derived:com.google.distance.delta:com.google.android.gms:aggregated",
"point": [
{
"startTimeNanos": "1673176936608000000",
"endTimeNanos": "1673181472006000000",
"dataTypeName": "com.google.distance.delta",
"originDataSourceId": "derived:com.google.distance.delta:com.google.android.gms:from_high_accuracy_location<-derived:com.google.location.sample:com.google.android.gms:merge_high_fidelity",
"value": [
{
"fpVal": 11273.688227319104,
"mapVal": []
}
]
}
]
},
{
"dataSourceId": "derived:com.google.distance.delta:com.google.android.gms:aggregated",
"point": [
{
"startTimeNanos": "1673176800000000000",
"endTimeNanos": "1673200789933000000",
"dataTypeName": "com.google.distance.delta",
"originDataSourceId": "raw:com.google.distance.delta:com.sec.android.app.shealth:health_platform",
"value": [
{
"fpVal": 14075.092156685667,
"mapVal": []
}
]
}
]
},
As you can see, there is no way of identifying which point maps to which activity.

Related

Elastic \ Opensearch life cycle management - what is the difference between read_write & open actions

I want to use life cycle management, the goal is to delete messages after 14 days
What should be the action in the first stage? Open or Read_write
What is the difference between the two actions?
{
"policy": {
"policy_id": "delete_after14_days",
"description": "index delete"
"schema_version": 1,
"error_notification": null,
"default_state": "open",
"states": [
{
"name": "hot",
"actions": [
{
**"open": {} or "read_write": {}**
}
],
"transitions": [
{
"state_name": "delete",
"conditions": {
"min_index_age": "14d"
}
}
]
},
{
"name": "delete",
"actions": [
{
"delete": {}
}
],
"transitions": []
}
],
"ism_template": [
{
"index_patterns": [
"audit-*"
],
"priority": 0
}
]
}
}

Get the count per status in micrometer #Timed annotation

I am using #Timed annotation in SpringBoot application to monitor a method. I also want to know the count of response per status.
#GetMapping("/status/{productNumber}", produces = [MediaType.APPLICATION_JSON_VALUE])
#Timed(value = "status.productnumber", description = "Timed information retrieveProduct()")
fun retrieveProduct(#PathVariable productNumber: String): ResponseEntity {
When I open http://localhost:8080/actuator/metrics/status.productnumber I see:
{
"name": "status.productnumber",
"description": "Timed information retrieveProduct()",
"base_unit": "seconds",
"measurements": [
{
"statistic": "COUNT",
"value": 3.0
},
{
"statistic": "TOTAL_TIME",
"value": 0.515840608
},
{
"statistic": "MAX",
"value": 0.006641343
}
],
"available_tags": [
{
"tag": "exception",
"values": [
"None",
"RuntimeException"
]
},
{
"tag": "method",
"values": [
"GET"
]
},
{
"tag": "uri",
"values": [
"/status/{productNumber}"
]
},
{
"tag": "outcome",
"values": [
"SERVER_ERROR",
"SUCCESS"
]
},
{
"tag": "status",
"values": [
"500",
"200"
]
}
]
}
Here the COUNT statistic shows the total number of times this endpoint or method is accessed. Can I know the count per status? I want to know how many times 500 status code has occurred
You can query the tags this way: /actuator/metrics/status.productnumber?tag=status:500, please see the docs.
A couple of side notes:
The metrics endpoint is for metrics debugging/troubleshooting purposes, it does not substitute a metrics backend, it should not be used instead of it in prod
I'm not sure I get what is the purpose of status.productnumber by reading its name

Delay in getting Google Fit API Response

I am using GoogleFit API to fetch the data I have added in the Gooogle Fit app, but it takes around 30 mins or so to get that data reflected in the API response.
API:
https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate
Request Body
{
"aggregateBy": [{
"dataTypeName": "com.google.blood_glucose"
},
{
"dataTypeName": "com.google.blood_pressure"
},
{
"dataTypeName": "com.google.heart_rate.bpm"
}],
"startTimeMillis": 1645446600000,
"endTimeMillis": 1645533000000
}
Response Body
{
"bucket": [
{
"startTimeMillis": "1645446600000",
"endTimeMillis": "1645533000000",
"dataset": [
{
"dataSourceId": "derived:com.google.blood_glucose:com.google.android.gms:merged",
"point": []
},
{
"dataSourceId": "derived:com.google.blood_pressure:com.google.android.gms:merged",
"point": []
},
{
"dataSourceId": "derived:com.google.heart_rate.bpm:com.google.android.gms:merge_heart_rate_bpm",
"point": []
}
]
}
]
}

Adaptive Cards Input Toggle(CheckBox) IOS issue

We have created bot using Microsoft bot-framework which is integrated to Microsoft teams. We have created few adaptive cards for interactive conversation with bot. One of the Adaptive card is causing design issue in IPhone X Microsoft Teams Application.
We used Adaptive card template for building this card which displays the list of Tasks along with status of the task. Each task has Input.Toggle (Checkbox) and at the end a button will be displayed. When Checkbox's are selected and button is clicked
We are sending new card with task details where they can edit the status and so on. Please find the JSON data below.
Card Payload Editor Json Data:
{
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "Container",
"border": true,
"items": [
{
"$data": "{properties}",
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "auto",
"items": [
{
"id": "{id}",
"type": "Input.Toggle",
"title": " ",
"value": "false",
"wrap": false
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "Container",
"items": [
{
"type": "FactSet",
"facts": [
{
"$data": "{peers}",
"title": "{key}",
"value": "{value}"
}
]
}
],
"style": "emphasis"
}
]
}
]
}
]
}
],
"actions": [
{
"type": "Action.Submit",
"title": "{actionSubmitTitle}",
"horizontalAlignment": "center"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}
Sample Data Editor:
"properties":[
{
"id":"InputToggle1",
"peers":[
{
"key":"Project",
"value":"' .$task->project_name. '"
},
{
"key":"Task",
"value":"'.$task->id.' - '.$task->heading.'"
},
{
"key":"Status",
"value":"'.$task->board_column.'"
}
]
},
{
"id":"InputToggle2",
"peers":[
{
"key":"Project",
"value":"' .$task->project_name. '"
},
{
"key":"Task",
"value":"'.$task->id.' - '.$task->heading.'"
},
{
"key":"Status",
"value":"'.$task->board_column.'"
}
]
},
{
"id":"InputToggle3",
"peers":[
{
"key":"Project",
"value":"' .$task->project_name. '"
},
{
"key":"Task",
"value":"'.$task->id.' - '.$task->heading.'"
},
{
"key":"Status",
"value":"'.$task->board_column.'"
}
]
},
{
"id":"InputToggle4",
"peers":[
{
"key":"Project",
"value":"' .$task->project_name. '"
},
{
"key":"Task",
"value":"'.$task->id.' - '.$task->heading.'"
},
{
"key":"Status",
"value":"'.$task->board_column.'"
}
]
}
],
"actionSubmitTitle":"Update Timesheet"
}
The InputToggle is inside the column set with width as auto and it is perfectly rendering in Microsoft Desktop and Android App but whereas in IOS app it is not showing
When we set the width property to stretch, InputToggle is getting displayed in IOS App in big size but in Desktop App and Android App the column is pushing and occupying much space.
Please help me so that we can display the Input.Toggle in IOS Microsoft Teams without breaking the design in Desktop and Android Teams App.
Edit: Adding final JSON sent to the bot. The columns in the column set will be changed dynamically based on the ask list in database.
{
"type":"AdaptiveCard",
"version":"1.0",
"body":[
{
"type":"Container",
"border":true,
"items":[
{
"type":"ColumnSet",
"columns":[
{
"type":"Column",
"width":"auto",
"items":[
{
"id":"inputToggle1",
"type":"Input.Toggle",
"title":" ",
"value":"false",
"wrap":false
}
]
},
{
"type":"Column",
"width":"stretch",
"items":[
{
"type":"Container",
"items":[
{
"type":"FactSet",
"facts":[
{
"title":"Project",
"value":"Project 1"
},
{
"title":"Task",
"value":"Task 1"
},
{
"title":"Status",
"value":"Pending"
}
]
}
],
"style":"emphasis"
}
]
}
]
},
{
"type":"ColumnSet",
"columns":[
{
"type":"Column",
"width":"auto",
"items":[
{
"id":"inputToggle2",
"type":"Input.Toggle",
"title":" ",
"value":"false",
"wrap":false
}
]
},
{
"type":"Column",
"width":"stretch",
"items":[
{
"type":"Container",
"items":[
{
"type":"FactSet",
"facts":[
{
"title":"Project",
"value":"Project 1"
},
{
"title":"Task",
"value":" Task 2"
},
{
"title":"Status",
"value":"Completed"
}
]
}
],
"style":"emphasis"
}
]
}
]
}
]
}
],
"actions":[
{
"type":"Action.Submit",
"title":"Update Timesheet",
"horizontalAlignment":"center"
}
],
"$schema":"http://adaptivecards.io/schemas/adaptive-card.json"
}
Thank you.
For completion, this was caused by a bug and is tracked as an Github Issue here:
https://github.com/microsoft/AdaptiveCards/issues/4052#

how to sort Data Sources in terraform based on arguments

I use following terraform code to get a list of available db resources:
data "alicloud_db_instance_classes" "resources" {
instance_charge_type = "PostPaid"
engine = "PostgreSQL"
engine_version = "10.0"
category = "HighAvailability"
zone_id = "${data.alicloud_zones.rds_zones.ids.0}"
multi_zone = true
output_file = "./classes.txt"
}
And the output file looks like this:
[
{
"instance_class": "pg.x4.large.2",
"storage_range": {
"max": "500",
"min": "250",
"step": "250"
},
"zone_ids": [
{
"id": "cn-shanghai-MAZ1(b,c)",
"sub_zone_ids": [
"cn-shanghai-b",
"cn-shanghai-c"
]
}
]
},
{
"instance_class": "pg.x8.medium.2",
"storage_range": {
"max": "250",
"min": "250",
"step": "0"
},
"zone_ids": [
{
"id": "cn-shanghai-MAZ1(b,c)",
"sub_zone_ids": [
"cn-shanghai-b",
"cn-shanghai-c"
]
}
]
},
{
"instance_class": "rds.pg.c1.xlarge",
"storage_range": {
"max": "2000",
"min": "5",
"step": "5"
},
"zone_ids": [
{
"id": "cn-shanghai-MAZ1(b,c)",
"sub_zone_ids": [
"cn-shanghai-b",
"cn-shanghai-c"
]
}
]
},
{
"instance_class": "rds.pg.s1.small",
"storage_range": {
"max": "2000",
"min": "5",
"step": "5"
},
"zone_ids": [
{
"id": "cn-shanghai-MAZ1(b,c)",
"sub_zone_ids": [
"cn-shanghai-b",
"cn-shanghai-c"
]
}
]
}
]
And I want to get the one that's cheapest.
One way to do so is by sorting with storage-range.min, but how do I sort this list based on 'storage_range.min'?
Or I can filter by 'instance_class', but "alicloud_db_instance_classes" doesn't seem to like filter as it says: Error: data.alicloud_db_instance_classes.resources: : invalid or unknown key: filter
Any ideas?
The sort() function orders lexicographical and you have no simple key here.
You can use filtering with some code like this (v0.12)
locals {
best_db_instance_class_key = "rds.pg.s1.small"
best_db_instance_class = element( alicloud_db_instance_classes.resources, index(alicloud_db_instance_classes.resources.*.instance_class, best_db_instance_class_key) )
}
(Untested code)

Resources