openScale icon indicating copy to clipboard operation
openScale copied to clipboard

Ryot sync support

Open IgnisDa opened this issue 2 years ago • 13 comments
trafficstars

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.

IgnisDa avatar Jul 26 '23 03:07 IgnisDa

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

oliexdev avatar Jul 29 '23 08:07 oliexdev

Yes, that is what I meant.

easy to use API

What kind of API is needed?

IgnisDa avatar Jul 29 '23 13:07 IgnisDa

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

oliexdev avatar Jul 30 '23 06:07 oliexdev

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.

oliexdev avatar Jul 30 '23 06:07 oliexdev

Cool, will update here when I implement them.

IgnisDa avatar Jul 30 '23 07:07 IgnisDa

@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.

  • insert: mutation createUserMeasurement
  • delete: mutation deleteUserMeasurement
  • update: delete and insert
  • list: query userMeasurementsList
  • clear: list then and delete in a loop

Please ping me here if anything else is needed.

IgnisDa avatar Aug 05 '23 17:08 IgnisDa

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

IgnisDa avatar Aug 19 '23 09:08 IgnisDa

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?

oliexdev avatar Aug 19 '23 13:08 oliexdev

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.

IgnisDa avatar Aug 23 '23 08:08 IgnisDa

How come that this feature request has the label question?

alexanderadam avatar Apr 20 '24 09:04 alexanderadam

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

IgnisDa avatar Apr 21 '24 11:04 IgnisDa

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:

alexanderadam avatar Apr 21 '24 12:04 alexanderadam

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.

IgnisDa avatar Apr 21 '24 12:04 IgnisDa