oliexdev / openScale

Open-source weight and body metrics tracker, with support for Bluetooth scales
GNU General Public License v3.0
1.68k stars 292 forks source link

Ryot sync support #973

Open IgnisDa opened 1 year ago

IgnisDa commented 1 year ago

Hello, awesome project! I am the developer of Ryot. I have started working on add fitness tracking support to my project and was recommended to check this project out.

I see that openScale has support for wger. Would you be willing to accept contributions for syncing with Ryot directly?

It would take me a couple of months to complete the fitness tracking support for Ryot and would like to add sync support after that.

oliexdev commented 1 year ago

Sure but I could implement that in openScale sync if it has a easy to use API and not directly in openScale.

IgnisDa commented 1 year ago

Yes, that is what I meant.

easy to use API

What kind of API is needed?

oliexdev commented 1 year ago

How are you typically implement your API? wger use the following REST API https://wger.de/api/v2/

oliexdev commented 1 year ago

But what I normally need for syncing are at least the following methods:

insert new measurement
delete a measurement
update a  measurement
get a list of all stored measurements
clear all measurements

I am using the date/time as an unique identifier for each measurement.

IgnisDa commented 1 year ago

Cool, will update here when I implement them.

IgnisDa commented 1 year ago

@oliexdev I added graphql queries/mutations for adding measurements.

First login to https://ryot.fly.dev and then https://ryot.fly.dev/settings/tokens generate a token. All requests to the graphql endpoint must have the header: X-Auth-Token: <copied-token>.

You can inspect the request and response structures in https://ryot.fly.dev/graphql.

Please ping me here if anything else is needed.

IgnisDa commented 1 year ago

Hello @oliexdev, any updates on this? Anything I can do to help?

oliexdev commented 1 year ago

I am not familiar with the graphQL, it seems more complex than the wger REST API. I am using retrofit2 to interact with the wger REST API.

Are you familiar with Android programming in Java? Or could you provide some curl examples for each operation?

IgnisDa commented 1 year ago

Yes, I am familiar. A graphql request can be converted to curl easily. Here is the request for creating a measurement.

curl 'https://ryot.fly.dev/graphql' -X POST -H 'Content-Type: application/json' --data-raw '{"query":"mutation CreateUserMeasurement($input: UserMeasurementInput!) {\n  createUserMeasurement(input: $input)\n}","variables":{"input":{"timestamp":"2023-08-23T08:08:28.676Z","name":"This is a test.","stats":{"weight":"78.900","muscle":"34.560"},"comment":"Some comment."}}}'

You can do it yourself by opening the network tab and using the "Copy as Curl" button for any graphql endpoint. You can get the contents of the query/mutation from here: https://github.com/IgnisDa/ryot/tree/main/libs/graphql/src/backend.

alexanderadam commented 4 months ago

How come that this feature request has the label question?

IgnisDa commented 4 months ago

For anyone following this, Ryot can now import from Openscale (v5.0.4).

alexanderadam commented 4 months ago

For anyone following this, Ryot can now import from Openscale (v5.0.4).

but this is a manual sync then, right?

And you probably created this issue back then to have an automatic sync via openScale sync, is that correct?

Either way I'd love to see an automatic sync. :wink:

IgnisDa commented 4 months ago

but this is a manual sync then, right?

Yes, it is meant as a one time import.

And you probably created this issue back then to have an automatic sync via openScale sync, is that correct?

Yes, I want Ryot sync to be added to Openscale Sync too hence this issue is still open.