Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev to main #46

Merged
merged 66 commits into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
610d6f5
Add plan scheduling
freekode Feb 26, 2024
2a8f612
TP rest for plans
freekode Feb 27, 2024
24dc26c
Merge branch 'main' into scheduling
freekode Feb 27, 2024
4804d87
Fix tests
freekode Feb 28, 2024
6c598b8
Fix tests
freekode Feb 28, 2024
448a354
Update main-branch.yml
freekode Feb 28, 2024
9614172
Merge pull request #31 from freekode/scheduling
freekode Feb 28, 2024
058aacd
Update workflows
freekode Feb 28, 2024
b00863d
Update workflows
freekode Feb 28, 2024
3475a26
Merge branch 'dev' into tp-copy-plan
freekode Feb 28, 2024
d4f941b
Get plans from TP
freekode Feb 28, 2024
35eeeee
Copy plans from TP
freekode Feb 29, 2024
9137718
Add rest, ui for copy plan
freekode Mar 1, 2024
49ad3be
Merge pull request #36 from freekode/update-java
freekode Mar 4, 2024
337f3d7
Merge branch 'dev' into tp-copy-plan
freekode Mar 5, 2024
65711ff
No dev in test
freekode Mar 5, 2024
e2d89f6
mock in tests
freekode Mar 5, 2024
44b5bc2
ignore test
freekode Mar 5, 2024
154659c
Add cache
freekode Mar 5, 2024
ed659f6
Merge pull request #38 from freekode/add-ehcache
freekode Mar 5, 2024
c84e958
Merge branch 'dev' into tp-copy-plan
freekode Mar 5, 2024
f054825
Add cache to api
freekode Mar 5, 2024
ae62860
fix tests
freekode Mar 5, 2024
5b9b977
replace real description
freekode Mar 5, 2024
c96caa4
refactor config
freekode Mar 6, 2024
d57d84b
Merge pull request #32 from freekode/tp-copy-plan
freekode Mar 6, 2024
1bdd216
Merge pull request #39 from freekode/main
freekode Mar 6, 2024
e1bfcec
Revert "main to dev"
freekode Mar 6, 2024
e2b57c1
Merge pull request #40 from freekode/revert-39-main
freekode Mar 6, 2024
89345ca
extract form to components
freekode Mar 6, 2024
26fd85b
remove walk training type
freekode Mar 6, 2024
d25c346
Merge pull request #41 from freekode/ref-ui
freekode Mar 7, 2024
70fe5fc
TP copy workouts from lib
freekode Mar 8, 2024
4f1c3ab
TP copy workouts ui
freekode Mar 9, 2024
656e595
refactor ui
freekode Mar 11, 2024
9221df2
repo name refactor
freekode Mar 11, 2024
024e966
copy whole library item
freekode Mar 11, 2024
0e31d7d
copy whole workouts
freekode Mar 11, 2024
fcd7f70
rename components
freekode Mar 11, 2024
a4029e9
fix tests
freekode Mar 11, 2024
1bd9857
fix tests
freekode Mar 11, 2024
099b5fb
Merge pull request #42 from freekode/tp-copy-workout
freekode Mar 11, 2024
a686187
Remove scheduling
freekode Mar 11, 2024
58c3ac2
Remove scheduling
freekode Mar 11, 2024
4a67451
Merge pull request #43 from freekode/remove-schedule
freekode Mar 11, 2024
10afeda
find tr workouts
freekode Mar 12, 2024
7322049
copy tr workout ui
freekode Mar 12, 2024
3f7730d
update ui, refactor operation names
freekode Mar 20, 2024
ff66448
fix copying, upd signature
freekode Mar 20, 2024
dfa23b8
hide under spolier all forms
freekode Mar 21, 2024
7c19c58
tr copy from calendar
freekode Mar 21, 2024
744b31a
add reset buttons
freekode Mar 21, 2024
2211645
update duration show
freekode Mar 21, 2024
325bb89
fix ui spacing
freekode Mar 21, 2024
86237af
fix tests
freekode Mar 21, 2024
5e2d26b
add workouts count
freekode Mar 21, 2024
65ea63d
add warn dialog
freekode Mar 21, 2024
a6d826c
updated menu
freekode Mar 21, 2024
18cb91c
upd ui budget
freekode Mar 21, 2024
4288e8f
fix cypress test
freekode Mar 21, 2024
85ea873
Merge pull request #45 from freekode/tr-copy-workout
freekode Mar 21, 2024
f8f3352
bulk workout save
freekode Mar 24, 2024
9fbe908
remove progress bar
freekode Mar 24, 2024
e3d4a2b
upd readme
freekode Mar 24, 2024
9a3f802
fix test
freekode Mar 24, 2024
94b2c73
fix plan copy
freekode Mar 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
name: Build main branch
name: Build branches

on:
push:
branches: [ main ]
branches: [ main, dev ]
paths-ignore:
- 'README.md'
- 'LICENSE'
workflow_dispatch:

concurrency:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-electron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Cache JDKs
uses: actions/cache@v4
with:
path: devops/jdktool/jdks
path: jdktool/jdks
key: ${{ runner.os }}-jdks

- name: Build jar in unix
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/build-jar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,16 @@ jobs:
cache: 'npm'
cache-dependency-path: 'ui/package-lock.json'

- name: Build project
run: ./devops/build-jar.sh
- name: Build UI
run: |
npm ci --prefix ui
npm run build --prefix ui

- name: Copy UI
run: cp -r ui/dist/ui/browser boot/src/main/resources/static

- name: Build boot
run: cd ./boot && ./gradlew build

- name: Cypress tests
run: |
Expand Down
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
[![release](https://img.shields.io/github/release/freekode/tp2intervals)](https://github.com/freekode/tp2intervals/releases/latest)

# Third Party to Intervals.icu
App to sync workouts and activities between TrainingPeaks and Intervals.icu.
App to sync workouts between TrainingPeaks, TrainerRoad and Intervals.icu.

* Sync planned workouts between Intervals.icu and TrainingPeaks for today and tomorrow (free TP account)
* Copy planned workouts for date range from TrainingPeaks to Intervals.icu Training Plan
**TrainingPeaks related features:**
* Sync planned workouts from Intervals to TrainingPeaks for today and tomorrow (free TP account)
* Copy whole training plan from TrainingPeaks
* Copy planned workouts for date range from TrainingPeaks to Intervals.icu training plan or workout folder

**TrainerRoad related features:**
* Copy workouts from TrainerRoad library to Intervals
* Copy planned workouts for date range from TrainerRoad to Intervals.icu training plan or workout folder

Executables for MacOS (DMG), Windows (EXE installer), Linux (AppImage) are available for download [here](https://github.com/freekode/tp2intervals/releases/latest)

Expand Down Expand Up @@ -53,9 +59,6 @@ services:
After you successfully started the application and were able to open the web UI page.
You need to configure it to gain access to Intervals.icu and to TrainingPeaks.

### TrainingPeaks Auth Cookie
Copy cookie `Production_tpAuth` (key and value, smth like `Production_tpAuth=very_long_string`) from the browser on TrainingPeaks page.

### Intervals API Key and Athlete Id
These values available on [Settings page](https://intervals.icu/settings) in Developer Settings section.

Expand All @@ -65,8 +68,15 @@ If everything is fine, you will be redirected to the home page, where you can pl
If your configuration is wrong. You will see an error that there is no access to TrainingPeaks or to Intervals.icu.
Check all your values and save configuration again.

### TrainingPeaks Auth Cookie
If you want ot use TrainingPeaks you need to configure it. Copy cookie `Production_tpAuth` (key and value, smth like `Production_tpAuth=very_long_string`) from the browser on TrainingPeaks page.

### TrainerRoad Auth Cookie
If you want to use TrainerRoad you need to configure it. Very similar to TrainerRoad. Copy cookie `TrainerRoadAuth` (key and value, smth like `TrainerRoadAuth=very_long_string`) from the browser on TrainerRoad page.

## FAQ
* Only duration based steps in workouts are supported, the app can't work with distance based steps
* Only duration based steps in workouts are supported, the app can't work with distance based steps
* Ramp steps in TrainerRoad are not supported
* **MacOS** app is not signed. Usually you need to open it twice. After opening it, be patient, it takes some time to start.
* **Windows** The app will ask to access local network and Internet allow it. After all it makes HTTP requests.
* Contact me in case of any problems. You can create an issue in [GitHub](https://github.com/freekode/tp2intervals/issues)
Expand Down
1 change: 1 addition & 0 deletions boot/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ dependencies {
implementation("org.xerial:sqlite-jdbc:3.45.0.0")
implementation("org.liquibase:liquibase-core")

implementation(group = "org.ehcache", name = "ehcache", classifier = "jakarta")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
Expand Down
3 changes: 3 additions & 0 deletions boot/src/main/kotlin/org/freekode/tp2intervals/Application.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package org.freekode.tp2intervals

import org.freekode.tp2intervals.infrastructure.dev.DevConfiguration
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.boot.runApplication
import org.springframework.cache.annotation.EnableCaching
import org.springframework.cloud.openfeign.EnableFeignClients

@SpringBootApplication
@EnableFeignClients
@EnableCaching
@EnableConfigurationProperties(DevConfiguration::class)
class Application

fun main(args: Array<String>) {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
package org.freekode.tp2intervals.app.activity

import org.freekode.tp2intervals.domain.Platform
import org.freekode.tp2intervals.domain.activity.ActivityRepository
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Service

@Service
class ActivityService(
private val activityRepositoryStrategy: ActivityRepositoryStrategy,
repositories: List<ActivityRepository>
) {
private val log = LoggerFactory.getLogger(this.javaClass)

private val repositoryMap = repositories.associateBy { it.platform() }

fun syncActivities(request: SyncActivitiesRequest) {
log.info("Sync activities by request $request")
val sourceActivityRepository = activityRepositoryStrategy.getRepository(request.sourcePlatform)
val targetActivityRepository = activityRepositoryStrategy.getRepository(request.targetPlatform)
val sourceActivityRepository = getRepository(request.sourcePlatform)
val targetActivityRepository = getRepository(request.targetPlatform)

val targetActivities = targetActivityRepository.getActivities(request.startDate, request.endDate)
.filter { request.types.contains(it.type) }
Expand All @@ -24,4 +28,6 @@ class ActivityService(
sourceActivities
.forEach { targetActivityRepository.createActivity(it) }
}

private fun getRepository(platform: Platform) = repositoryMap[platform]!!
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.freekode.tp2intervals.app.confguration

import org.freekode.tp2intervals.domain.Platform
import org.freekode.tp2intervals.domain.config.AppConfiguration
import org.freekode.tp2intervals.domain.config.AppConfigurationRepository
import org.freekode.tp2intervals.domain.config.PlatformConfigurationRepository
Expand All @@ -12,6 +13,8 @@ class ConfigurationService(
private val platformConfigurationRepositories: List<PlatformConfigurationRepository>,
private val appConfigurationRepository: AppConfigurationRepository
) {
private val repositoryMap = platformConfigurationRepositories.associateBy { it.platform() }

fun getConfiguration(key: String): String? = appConfigurationRepository.getConfiguration(key)

fun getConfigurations(): AppConfiguration = appConfigurationRepository.getConfigurations()
Expand All @@ -20,6 +23,10 @@ class ConfigurationService(
return platformConfigurationRepositories.mapNotNull { updateConfiguration(request, it) }
}

fun isValid(platform: Platform): Boolean {
return repositoryMap[platform]!!.isValid()
}

private fun updateConfiguration(
request: UpdateConfigurationRequest,
repository: PlatformConfigurationRepository
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.freekode.tp2intervals.app.plan

import org.freekode.tp2intervals.domain.Platform
import org.freekode.tp2intervals.domain.librarycontainer.LibraryContainer

data class CopyLibraryRequest(
val libraryContainer: LibraryContainer,
val newName: String,
val sourcePlatform: Platform,
val targetPlatform: Platform,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.freekode.tp2intervals.app.plan

data class CopyPlanResponse(
val planName: String,
val workouts: Int,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.freekode.tp2intervals.app.plan

import org.freekode.tp2intervals.domain.Platform
import org.freekode.tp2intervals.domain.librarycontainer.LibraryContainer
import org.freekode.tp2intervals.domain.librarycontainer.LibraryContainerRepository
import org.freekode.tp2intervals.domain.workout.WorkoutRepository
import org.freekode.tp2intervals.infrastructure.utils.Date
import org.springframework.stereotype.Service

@Service
class LibraryService(
workoutRepositories: List<WorkoutRepository>,
planRepositories: List<LibraryContainerRepository>,
) {
private val workoutRepositoryMap = workoutRepositories.associateBy { it.platform() }
private val planRepositoryMap = planRepositories.associateBy { it.platform() }

fun getLibraryContainers(platform: Platform): List<LibraryContainer> {
val repository = planRepositoryMap[platform]!!
return repository.getLibraryContainer()
}

fun copyLibrary(request: CopyLibraryRequest): CopyPlanResponse {
val targetPlanRepository = planRepositoryMap[request.targetPlatform]!!
val sourceWorkoutRepository = workoutRepositoryMap[request.sourcePlatform]!!
val targetWorkoutRepository = workoutRepositoryMap[request.targetPlatform]!!

val workouts = sourceWorkoutRepository.getWorkoutsFromLibrary(request.libraryContainer)
val newPlan = targetPlanRepository.createLibraryContainer(request.newName, Date.thisMonday(), true)
targetWorkoutRepository.saveWorkoutsToLibrary(newPlan, workouts)
return CopyPlanResponse(newPlan.name, workouts.size)
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import java.time.LocalDate
import org.freekode.tp2intervals.domain.Platform
import org.freekode.tp2intervals.domain.TrainingType

data class PlanWorkoutsRequest(
class CopyFromCalendarToCalendarRequest(
val startDate: LocalDate,
val endDate: LocalDate,
val types: List<TrainingType>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ package org.freekode.tp2intervals.app.workout
import java.time.LocalDate
import org.freekode.tp2intervals.domain.Platform
import org.freekode.tp2intervals.domain.TrainingType
import org.freekode.tp2intervals.domain.plan.PlanType

data class CopyWorkoutsRequest(
data class CopyFromCalendarToLibraryRequest(
val name: String,
val planType: PlanType,
val isPlan: Boolean,
val startDate: LocalDate,
val endDate: LocalDate,
val types: List<TrainingType>,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.freekode.tp2intervals.app.workout

import org.freekode.tp2intervals.domain.Platform
import org.freekode.tp2intervals.domain.librarycontainer.LibraryContainer
import org.freekode.tp2intervals.domain.workout.WorkoutDetails
import org.freekode.tp2intervals.rest.workout.WorkoutDetailsDTO

class CopyFromLibraryToLibraryRequest(
val workoutDetails: WorkoutDetailsDTO,
val targetLibraryContainer: LibraryContainer,
val sourcePlatform: Platform,
val targetPlatform: Platform,
)

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading