How to create "mile markers" on route map and/or "kilometer split/pace" chart in a Google Fit session summary? - google-fit

I have created a python script that is able to connect to Google Fit, create an activity, upload datapoints and create a "session" based on activity data that I am extracting from Huawei Health via HiTrack files.
However, the sessions that I am creating do not show "mile markers" on the route map, nor does it show each kilometer time split in the "speed" summary, like the ones shown on "automatically tracked" sessions.
For instance, here are the map and "speed" section from an "automatically tracked" cycle session (ie. the phone in my backpack detected I was out cycling and recorded this data):
Map with "mile markers"
Speed section showing kilometer "splits"/pace
However, after uploading data using my script, I get this:
"Map with no markers"
"Speed section with no splits or pace info"
Is there a particular datatype or datapoint record that I need to be inserting to get these "mile markers" to show on the map?
And is there a particular datatype or datapoint record that I need to be inserting to get the kilometer splits/pace records to show in the "speed" section?

Related

Google Fit Running data

I am using Google API Client for fitness to retrieve user fitness data using the PHP Client library.
My usecase: To get users Total run time for the day, and also distance.
I am using the following code (sample code with key steps):
$service = new Google_Service_Fitness($google_client);
$dataSets = $service->users_dataset;
..
$aggBy->setDataTypeName("com.google.activity.segment");
..
$aggregates = $dataSets->aggregate('me',$aggReq);
I am using com.google.activity.segment as datatypename:
I get a response with run type with data
Activity type: 8
runtime : value in msec
no of segment: 2
Now i want to get the total distance travelled during running session,
From above response i can make out that user had 2 separate running activity, then how i can get the combined distance done by the particular activity?
Also how i can retrieve details about these in 2 running segment in details?
As said i am using PHP Client API.

Mass Upload Files To Specific Contacts Salesforce

I need to upload some 2000 documents to specific users in salesforce. I have a csv file that has the Salesforce-assigned ContactID, as well as a direct path to the files on my desktop. Each contact's specific file url has been included in the csv. How can I upload them all at one and, especially, to the correct contact?
You indicated in the comments / chat that you want it as "Files".
The "Files" object is bit more complex than Attachments, you'll need to do it in 2-3 steps. What you see as a File (you might see it referred to in documentation as Chatter Files or Salesforce Content) is actually several tables. There's
ContentDocument which can be kind of a file header (title, description, language, tags, linkage to many other areas in SF - because it can be standalone, it can be uploaded to certain SF Content Library, it can be linked to Accounts, Contacts, $_GOD knows what else)
ContentVersion which is well, actual payload. Only most recent version is displayed out of the box but if you really want you can go back in time
and more
The crap part is that you can't insert ContentDocument directly (there's no create() call in the list of operations) .
Theory
So you'll need:
Insert ContentVersion (v1 will automatically create for you parent ContentDocuments... it does sound bit ass-backwards but it works). After this is done you'll have a bunch of standalone documents loaded but not linked to any Contacts
Learn the Ids of their parent ContentDocuments
Insert ContentDocumentLink records that will connect Contacts and their PDFs
Practice
This is my C:\stacktest folder. It contains some SF cheat sheet PDFs.
Here's my file for part 1 of the load
Title PathOnClient VersionData
"Lightning Components CheatSheet" "C:\stacktest\SF_LightningComponents_cheatsheet_web.pdf" "C:\stacktest\SF_LightningComponents_cheatsheet_web.pdf"
"Process Automation CheatSheet" "C:\stacktest\SF_Process_Automation_cheatsheet_web.pdf" "C:\stacktest\SF_Process_Automation_cheatsheet_web.pdf"
"Admin CheatSheet" "C:\stacktest\SF_S1-Admin_cheatsheet_web.pdf" "C:\stacktest\SF_S1-Admin_cheatsheet_web.pdf"
"S1 CheatSheet" "C:\stacktest\SF_S1-Developer_cheatsheet_web.pdf" "C:\stacktest\SF_S1-Developer_cheatsheet_web.pdf"
Fire Data Loader, select Insert, select showing all Salesforce objects. Find ContentVersion. Load should be straightforward (if you're hitting memory issues set batch size to something low, even 1 record at a time if really needed).
You'll get back a "success file", it's useless. We don't need the Ids of generated content versions, we need their parents... Fire "Export" in Data Loader, pick all objects again, pick ContentDocument. Use query similar to this:
Select Id, Title, FileType, FileExtension
FROM ContentDocument
WHERE CreatedDate = TODAY AND CreatedBy.FirstName = 'Ethan'
You should see something like this:
"ID","TITLE","FILETYPE","FILEEXTENSION"
"0690g0000048G2MAAU","Lightning Components CheatSheet","PDF","pdf"
"0690g0000048G2NAAU","Process Automation CheatSheet","PDF","pdf"
"0690g0000048G2OAAU","Admin CheatSheet","PDF","pdf"
"0690g0000048G2PAAU","S1 CheatSheet","PDF","pdf"
Use Excel and magic of VLOOKUP or other things like that to link them back by title to Contacts. You wrote you already have a file with Contact Ids and titles so there's hope... Create a file like that:
ContentDocumentId LinkedEntityId ShareType Visibility
0690g0000048G2MAAU 0037000000TWREI V InternalUsers
0690g0000048G2NAAU 0030g000027rQ3z V InternalUsers
0690g0000048G2OAAU 0030g000027rQ3a V InternalUsers
0690g0000048G2PAAU 0030g000027rPz4 V InternalUsers
1st column is the file Id, then contact Id, then some black magic you can read about & change if needed in ContentDocumentLink docs.
Load it as insert to (again, show all objects) ContentDocumentLink.
Woohoo! Beer time.
Your CSV should contain following fields :
- ParentID = Id of object you want to link the attachment to (the ID of the contact)
- Name = name of the file
- ContentType = extension(.xls or .pdf or ...)
- OwnerId = if empty I believe it takes your user as owner
- body = the location on your machine of the file (for instance: C:\SFDC\Files\test.pdf
Use this csv to insert the records (via data loader) into the Attachment object.
You will then see for each contact, that records have been added to the 'Notes & Attachments' related list.

Kibana Visualizations with JSON Codec

I set up a server with ELK stack and started feeding logs into it.
The logs are in JSON format, so I edited the LogStash conf file to use the JSON Codec.
When I enter the Kibana Discover page I see that the JSON is indeed decoded - it's no longer just a long string, every field is separated as it should be.
But now I want to create visualizations based on these fields, for example: There is a field named "service" which names the service which created the log record. I would like to create a vertical bar visualization using the "service" field for the X-axis.
How do I do such a thing?
You can create visualizations easily by following below mentioned steps:-
Click on Visualize Tab
Select Visualization type as "Vertical Bar Chart"
Select search from data source
Select count in Y-Axis
Select Terms in X-Axis & select your field named as service

Fusion Tables / KML preserve or merge attributes to permit queries

I have created a .kml polygonal file from a shapefile. I then create a fusion table uploading the .kml . I want to be able to query the attributes of the shapefile but all the attributes are loaded into an html object "description." Not only do I want to be able to query the attribute table but I want the to preserve the polygonal features as a layer in the map.
I figure there are at least 2 ways to solve this problem:
a) merge the KML fusion table with an identical fusion table layer containing all attributes (i.e. exported as a .csv)
- I have tried this by merging the location attribute data with the geometry column and it does not preserve the polygonal features.
If I can merge the 2 tables succesfully (preserving polygonal features and attributes) using a column other than geometry/location - how can I generate a set of unique ID's within Google Fusion Tables that will be consistent for each table?
b) extract the attributes from within the html object "description" as new columns.
I found the answer from pvanb's helpful blog
To Quote him:-
"In QGIS you use the ‘save as’ option in QGIS. You can get this using the context menu (right click mouse on the layer) or the menu ‘Layer | Save as..’. In the menu that opens, there are two fields under the header ‘OGR creation options’; ‘Data source’ and ‘Layer’.
In the ‘Data source’ field, you can define which columns you want to use to fill the Name and Description fields in your kml file. You do this by defining the NameField and the DescriptionField. For example, NameField=PNVname and DescriptionField=PNVcode."
There are more options but basically what I have found is that by listing only Namefield= (unique ID table) and ignoring the DescriptionField entirely all the columns of data from the shapefile are preserved and thus there is no need to even merge another table and you get Polygons!
Fantastic

Allow users to add markers based on name of places instead of coordinates and then allow then to filter

I have a group of 10 volunteers who will distribute flyers in different areas. I want to make a web page where they can login and then add their markers by searching for the place instead of coordinates (if believe its done through Geocoding??). Then once the user is logged in I want them to filter the markers by "My markers" and "All markers" category.
So 2 things. How to make the user search using name instead of coordinates and add the marker. And second, how to filter the markers.
Thanks
Karan
Have you read
https://developers.google.com/maps/documentation/javascript/geocoding#GeocodingStatusCodes
? Then keep track of users' markers with an object referencing a Marker array, such as user['bob'] = [marker 1, marker 2, etc.] and switch on and off based on these user names.
When you run into a specific problem come back here.
Yes you are right you should use geocoding to get the user to the exact spot he wants.Then you can add the user markers in your database together with the userid so you can filter them by mymarkers.