jaamo / strava2kilometrikisa

Node web app for synchronizing activities from Strava to kilometrikisa.
10 stars 9 forks source link

New setup #34

Closed onefastsnail closed 4 years ago

onefastsnail commented 4 years ago

Changes

No real code changes or code improvements but rather focusing on developer experience and helping the overall maintenance of the project by creating a simpler easy stack to develop with. Allowing others to contribute more easily, hopefully 😅 .

This sat on machine for quite sometime, only until recent activity i then was reminded i had this, so here we go... 😄

The Prettier change makes this PR slightly harder to look at, should have done this in a new PR, my bad.

The unchecked items i figured would be best in a separate PRs and not further extend this chaotic PR.

I have a working demo at https://strava2kilometrikisa.herokuapp.com with the pipelines implemented.

The flow would go as follows:

  1. Feature branch development
  2. Pull request into master
  3. Once merged into master, a UAT version is automatically built and deployed to https://strava2kilometrikisa-uat.herokuapp.com.
  4. Then once we are happy with it we can promote to the live env. Up next we could add the Review Apps integration in Heroku to allow easier PR reviews. But i figured for now the above will suffice.

I originally tried to detach the sync to a scheduled event, but our sync service requires X time per registered user whilst syncing, so such a call could take minutes and only grows with users, where the worker feels more capable in this use case. However the daily restart of Heroku dynos may occur during a sync, for now i would suggest to run the sync twice a day to at least get a successful sync once a day. The API rate limits "should" be fine 😅 .

Both demo versions use a test MongoDB so feel free to spam and test. Sync is 4am on both environments.

Moving forward

  1. To point to the current DNS to our friends at Heroku
  2. We are currently using a free tier on Heroku, so the dyno will sleep, we may want to bump to the Hobby tier to alleviate this issue, or at least create a dedicated strava2kilometrikisa, as its currently under my account.
  3. And Enjoy :).
hugovk commented 4 years ago

Well, the working demo worked to manually sync my existing activities for the last week! 👍

onefastsnail commented 4 years ago

Awesome! And thanks for the feedback @hugovk, will get onto these changes tomorrow 😄.

onefastsnail commented 4 years ago

Currently putting a fix onto #32 to query the Strava APIs only once the updateToken method has resolved, ie with a token. BRB 😄

onefastsnail commented 4 years ago

Any further input on this @jaamo, @hugovk and @Mattti0? 😄

onefastsnail commented 4 years ago

I've started using the demo site each day to manually sync.

Awesome!

I guess there's no cron on the demo site, either that some missing settings or a bug in updating each day.

Yeh the worker was disabled as it would eat away at my Heroku allowance 😅. It is now running and will run a sync at 22:00 tonight if you want to test this @hugovk?

hugovk commented 4 years ago

It is now running and will run a sync at 22:00 tonight if you want to test this @hugovk?

Yes, will report back!

onefastsnail commented 4 years ago

Turned out I created an issue regarding a lack of persisting the user token to the DB which now seems kind of obvious 😅 and the usage of the newly generated token once the promise resolves, all of which have been fixed and deployed to both UAT and LIVE environments of the demo site.

The worker did run at 22:00 as intended, looped through the users in the test DB, all of which failed to query the Strava API due to invalid tokens. So debugging locally and running a local worker with this fix, all worked and sync all test DB users.

Mattti0 commented 4 years ago

Seems like it has automatically synced also my data to Kilometrikisa! Last time I logged to site was maybe about week ago. Thanks!

hugovk commented 4 years ago

👍 Yesterday's 18:00 ride has been synced fine to Kilometrikisa.

onefastsnail commented 4 years ago

Thanks for the feedback @Mattti0 and @hugovk.

I just ran the worker on the new production demo environment and it synced all the DB users activities, and testing my Kilometrikisa data, all looks 👌 this morning.

And @Mattti0's token refresh fix worked perfect to update the short-lived access tokens.

If all ok with everyone, I will merge this to master and speak with @jaamo to update the DNS.

Thanks for all your help! 😄

hugovk commented 4 years ago

The new setup has been working well so far!

I have a gap for the 1-22 January, would it be possible to set up a demo site to sync those dates? Or do you have instructions on how to set it up locally to do so?

Thanks!