how can I get google fit data's - node.js

Hi how can I get the activity from google fit data. I have almost done all aspects after getting the access token how can I get the google fit datas, by using the below code I can get only this kind of response
code:
gFit.listExistingSessions(req.query.token,function(status,data){
// console.log('Sessions',data);
res.render('results', { resp: data });
});
response:
"session": [
{
"id": "3116a82009dd6cd7:activemode:running:1456064572752",
"startTimeMillis": "1456064572752",
"endTimeMillis": "1456114372880",
"modifiedTimeMillis": "1456745578987",
"application": {
"packageName": "com.google.android.apps.fitness"
},
"activityType": 8
},
{
"id": "3116a82009dd6cd7:activemode:running:1456064572752",
"name": "Evening running",
"startTimeMillis": "1456064572752",
"endTimeMillis": "1456114370411",
"modifiedTimeMillis": "1456745578992",
"application": {
"packageName": "com.google.android.apps.fitness"
},
"activityType": 8
},
{
"id": "3116a82009dd6cd7:activemode:biking:1456742139081",
"startTimeMillis": "1456742139081",
"endTimeMillis": "1456742187907",
"modifiedTimeMillis": "1456745578998",
"application": {
"packageName": "com.google.android.apps.fitness"
},
"activityType": 1
}
]
Can any one tell me how to get the calories burned, steps count, miles and minutes of each of the sessions.

According to their documentation, sessions are only a mean of organizing workouts, but they do not provide specific workout data. For that, you have to query datasets that overlap with the time interval of the session.
For more information on how to query specific datasets, see Working with datasets.
This is the example request for querying datasets:
https://www.googleapis.com/fitness/v1/users/me/dataSources/derived:com.google.step_count.delta:1234567890:Example%20Manufacturer:ExampleTablet:1000001/datasets/1397513334728708316-1397515179728708316
There, you have to replace com.google.step_count.delta with whatever data type you require, and also replace the timestamps at the end of the query with the ones that match your session start and end times.

Related

Shopware 6 API: Update an existing product without stock or price

It is very common that the stock entries of a product are updated in the shop by a different ERP system than the system that updates the product information (number, properties, etc.). Shopware 6 does not seem to support this method and throws the error seen below.
I do understand that for the initial creation of a product there are some required fields like productNumber or stock but when updating an already existing product, it should be totally fine to leave those values out, so that they can be updated by an external system.
This worked in Shopware 5 but not in Shopware 6. Does anyone know a workaround?
(I am thinking about sending the existing value from Shopware because then it is technically not updated but that is my last resort.)
Array
(
[code] => c1051bb4-d103-4f74-8988-acbcafc7fdc3
[status] => 400
[detail] => This value should not be blank.
[template] => This value should not be blank.
[meta] => Array
(
[parameters] => Array
(
[{{ value }}] => null
)
)
[source] => Array
(
[pointer] => /0/stock
)
)
Full example for a request payload
{
"newData": {
"action": "upsert",
"entity": "product",
"payload": [
{
"id": "206c59a3339383101655aae7598e328c",
"language": "default",
"taxId": "6460303d84264f36858d1fe9e8c2f60f",
"name": "SLT 95 Nano Crystal",
"active": true,
"visibilities": [
{
"id": "d43840cff1b2bcc741a9a83ebb5b3c16",
"salesChannelId": "e8d8fd2337dd42e0a86b47ea68739824",
"visibility": 30
}
],
"categories": [
{
"id": "66ca2d80dc532d4d6659b4430e6954a8"
}
],
"description": "A not so much very short text. Another short text.",
"price": [
{
"net": 9999.99,
"gross": 9999.99,
"linked": true,
"currencyId": "b7d2554b0ce847cd82f3ac9bd1c0dfca"
}
],
"productNumber": "P_10254",
"crossSellings": [
{
"id": "b3e3171397d30794171877fed2329d96",
"name": "Similar Products",
"assignedProducts": [],
"type": "productList",
"active": true,
"sortBy": "name",
"sortDirection": "ASC",
"limit": 24,
"position": 1
}
]
}
]
}
}
Short example for a request payload
"payload": [
{
"id": "206c59a3339383101655aae7598e328c",
"language": "default",
"taxId": "6460303d84264f36858d1fe9e8c2f60f",
"name": "SLT 95 Nano Crystal",
"active": true,
...
}
]
I simply do not send the stock for a normal product upsert in hopes that Shopware uses the already existing stock.
With the version "v6.4.4.1 Stable Version" Shopware introduced a concept change which allows you to update existing products without having to send all required fields.
This solves this issue and is very useful if for example the stocks shall be maintained by hand and not be controlled by the API calls.

How do I retrieve multiple callbacks on translation progress

I have created a webhook that is using the even extraction.updated that should trigger when a job is in progress. I want to retrieve multiple calls on the progress of the translation so that I can show it in my progress bar. Unfortunately I only retrieve a callback when the job translation is finished. When I create the job I set the misc.workflow parameter and same goes for the hook. Am I missing some parameters when creating a webhook or posting a job?
I was following this tutorial: https://forge.autodesk.com/en/docs/webhooks/v1/tutorials/create-a-hook-model-derivative/
The job payload takes the input which is my urn, output which is the filetype(svf2) and views(2d,3d), and misc which is the workflow(testworkflowname)
Callback result:
{{
"version": "1.0",
"resourceUrn": "<my-resourceUrn>",
"hook": {
"hookId": "<my-hookId>",
"tenant": "testworkflowname",
"callbackUrl": "<my-callbackUrl>",
"createdBy": "<my-createdBy>",
"event": "extraction.updated",
"createdDate": "<my-createdDate>",
"lastUpdatedDate": "<my-lastUpdatedDate>",
"system": "derivative",
"creatorType": "Application",
"status": "active",
"scope": {
"workflow": "testworkflowname"
},
"hookAttribute": {
"progress": "test"
},
"autoReactivateHook": false,
"urn": "<my-urn>"
},
"payload": {
"TimeStamp": <my-timestamp>,
"Env": "production",
"URN": "<my-urn>",
"EventType": "UPDATED",
"Payload": {
"status": "success",
"bubble": {
"guid":"<my-guid>",
"owner": "<my-owner>",
"hasThumbnail": "true",
"startedAt": "my-startedAt>",
"type": "design",
"urn":"<my-urn>",
"success": "100%",
"progress": "complete",
"region": "US",
"status": "success",
"children": []
},
"scope": "<my-scope>",
"registerKey": []
},
"WorkflowAttributes": null
}
}}
You've got your webhooks setup correctly. I'm afraid this is a limitation on the Model Derivative service side. The service can translate over 60 different file formats today, and as you can imagine, different formats must be converted using different libraries. And while some of the converters support progress reporting, others may not, so being able to get notified of translation progress really depends on the file format you're processing.

Can I index an array in a composite index in Azure Cosmos DB?

I have a problem indexing an array in Azure Cosmos DB
I am trying to save this indexing policy via the portal
{
"indexingMode": "consistent",
"automatic": true,
"includedPaths": [
{
"path": "/*"
}
],
"excludedPaths": [
{
"path": "/\"_etag\"/?"
}
],
"compositeIndexes": [
[
{
"path": "/DeviceId",
"order": "ascending"
},
{
"path": "/TimeStamp",
"order": "ascending"
},
{
"path": "/Items/[]/Name/?",
"order": "ascending"
},
{
"path": "/Items/[]/DoubleValue/?",
"order": "ascending"
}
]
]
}
I get the error "Failed to update container DeviceEvents:
Message: {"code":"BadRequest","message":"Message: {"Errors":["The indexing path '\/Items\/[]\/Name\/?' could not be accepted, failed near position '8'."
This seems to be the array [] syntax that is giving an error.
On a side note I am not sure what I am doing makes sense at all but I have a query that looks like this
SELECT SUM(de0["DoubleValue"])
FROM root JOIN de0 IN root["Items"]
WHERE root["ApplicationId"] = 57 AND root["DeviceId"] = 126 AND root["TimeStamp"] >= "2021-02-21T17:55:29.7389397Z" AND de0["Name"] = "Use Case"
Where ApplicationId is the partition key and the item saved looks like this
{
"id": "59ab9323-26ca-436f-8d29-e1ddd826f025",
"DeviceId": 3,
"ApplicationId": 3,
"RawData": "640F7A000A00E30142000000",
"TimeStamp": "2021-02-20T18:36:52.833174Z",
"Items": [
{
"Name": "Battery Status",
"StringValue": "Full",
"DoubleValue": null
},
{
"Name": "Use Case",
"StringValue": null,
"DoubleValue": 12
},
{
"Name": "Battery Voltage",
"StringValue": null,
"DoubleValue": 3.962
},
{
"Name": "Rain Gauge Count",
"StringValue": null,
"DoubleValue": 10
}
],
"_rid": "CgdVAO7B0DNkAAAAAAAAAA==",
"_self": "dbs/CgdVAA==/colls/CgdVAO7B0DM=/docs/CgdVAO7B0DNkAAAAAAAAAA==/",
"_etag": "\"61008771-0000-0d00-0000-603156c50000\"",
"_attachments": "attachments/",
"_ts": 1613846213
}
I need to aggregate on some of these items in the array like say get MAX on temperature or something like this (using Use Case for test although it doesn't make sense). I reasoned that if all the data in the query is in a single composite index the database would be able to do the aggregation without reading the documents themselves. However I can't seem to add a composite index containing an array at all.
Yes, composite index can't contain an array path. It should be a scalar value.
Unlike with included or excluded paths, you can't create a path with
the /* wildcard. Every composite path has an implicit /? at the end of
the path that you don't need to specify. Composite paths lead to a
scalar value and this is the only value that is included in the
composite index.
Reference:https://learn.microsoft.com/en-us/azure/cosmos-db/index-policy#composite-indexes

How to query by array of objects in Contentful

I have an content type entry in Contentful that has fields like this:
"fields": {
"title": "How It Works",
"slug": "how-it-works",
"countries": [
{
"sys": {
"type": "Link",
"linkType": "Entry",
"id": "3S5dbLRGjS2k8QSWqsKK86"
}
},
{
"sys": {
"type": "Link",
"linkType": "Entry",
"id": "wHfipcJS6WUSaKae0uOw8"
}
}
],
"content": [
{
"sys": {
"type": "Link",
"linkType": "Entry",
"id": "72R0oUMi3uUGMEa80kkSSA"
}
}
]
}
I'd like to run a query that would only return entries if they contain a particular country.
I played around with this query:
https://cdn.contentful.com/spaces/aoeuaoeuao/entries?content_type=contentPage&fields.countries=3S5dbLRGjS2k8QSWqsKK86
However get this error:
The equals operator cannot be used on fields.countries.en-AU because it has type Object.
I'm playing around with postman, but will be using the .NET API.
Is it possible to search for entities, and filter on arrays that contain Objects?
Still learning the API, so I'm guessing it should be pretty straight forward.
Update:
I looked at the request the Contentful Web CMS makes, as this functionality is possible there. They use query params like this:
filters.0.key=fields.countries.sys.id&filters.0.val=3S5dbLRGjS2k8QSWqsKK86
However, this did not work in the delivery API, and might only be an internal query format.
Figured this out. I used the following URL:
https://cdn.contentful.com/spaces/aoeuaoeua/entries?content_type=contentPage&fields.countries.sys.id=wHfipcJS6WUSaKae0uOw8
Note the query parameter fields.countries.sys.id

Get session using start time and end time in google fit

When I tried to get the sessions based on start and end time, I can get only the named sessions(like Morning walking in the image) but not other sessions. Can any one tell me why this kind of data's not fetched.
API:
https://www.googleapis.com/fitness/v1/users/me/sessions?startTime=2016-03-08T00:00:00.000Z&endTime=2016-03-08T22:00:00.000Z&access_token=*******
Not only this date but also for all the date, I have gets only the named sessions.
Response:
{
"session": [
{
"id": "b514327692edd309:activemode:walking:1457414580406",
"name": "Morning walking",
"startTimeMillis": "1457414580406",
"endTimeMillis": "1457414781711",
"modifiedTimeMillis": "1457415751927",
"application": {
"packageName": "com.google.android.apps.fitness"
},
"activityType": 7
}
]
}

Resources