diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 91290dcd..206b859d 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -103,14 +103,20 @@ export function arrayAverage(arr: number[]): number { export function averagePercentageChange(arr: number[]): number { if (arr.length < 2) return 0; - const totalPercentageChange = arr.slice(1).reduce((sum, current, index) => { - const previous = arr[index]; + let totalPercentageChange = 0; + let numberOfIncrements = 0; + + for (let i = 1; i < arr.length; i++) { + const previous = arr[i - 1]; + const current = arr[i]; + if (previous === 0 || current === 0) continue; + const percentageChange = ((current - previous) / previous) * 100; - return sum + (isNaN(percentageChange) ? 0 : percentageChange); - }, 0); + totalPercentageChange += isNaN(percentageChange) ? 0 : percentageChange; + numberOfIncrements++; + } - const numberOfIncrements = arr.length - 1; - return totalPercentageChange / numberOfIncrements; + return numberOfIncrements > 0 ? totalPercentageChange / numberOfIncrements : 0; } export function convertCamelCaseToNormal(text?: string | null): string { diff --git a/src/routes/(components)/layout/NavLinks.svelte b/src/routes/(components)/layout/NavLinks.svelte index ac4cfd03..6f684bcd 100644 --- a/src/routes/(components)/layout/NavLinks.svelte +++ b/src/routes/(components)/layout/NavLinks.svelte @@ -1,23 +1,40 @@ diff --git a/src/routes/dashboard/+page.server.ts b/src/routes/dashboard/+page.server.ts index bde9acd3..71cf1654 100644 --- a/src/routes/dashboard/+page.server.ts +++ b/src/routes/dashboard/+page.server.ts @@ -1,13 +1,13 @@ import { createContext } from '$lib/trpc/context'; import { createCaller } from '$lib/trpc/router'; -import { redirect } from '@sveltejs/kit'; +import { error } from 'console'; export const load = async (event) => { event.depends('workouts:all'); const session = await event.locals.auth(); if (session === null) { - redirect(302, '/'); + error(401, 'Not logged in'); } const trpc = createCaller(await createContext(event)); diff --git a/src/routes/docs/+page.server.ts b/src/routes/docs/+page.server.ts new file mode 100644 index 00000000..189f71e2 --- /dev/null +++ b/src/routes/docs/+page.server.ts @@ -0,0 +1 @@ +export const prerender = true; diff --git a/src/routes/docs/+page.svelte b/src/routes/docs/+page.svelte new file mode 100644 index 00000000..a0f82def --- /dev/null +++ b/src/routes/docs/+page.svelte @@ -0,0 +1,37 @@ +
+

Docs

+
Just a basic overview of things work in this app, as there are some differences from V2
+ +

Exercise splits

+

+ An exercise split refers to how workout sessions are divided across different days to target specific muscle groups + or movement patterns. Examples: Push Pull Legs, Upper Lower, and Full Body. +

+

Tha app supports both synchronous (weekly) splits, and asynchronous splits (non-weekly) splits.

+ +

Mesocycle

+

+ A mesocycle is a unit of training consisting of several microcycles (repeated splits), usually lasting 4-6 weeks. + The mesocycle structures progression and recovery, with increasing intensity or volume followed by deload phases to + avoid overtraining. Deload feature will be coming soon! +

+ +

Workouts

+

+ A single workout, consisting of multiple exercises, each with their own sets and options. Workouts can be done with + or without an active mesocycle. +

+

Using an active mesocycle allows the app to progress performance and sets every microcycle.

+ +

Mesocycle exercise split

+

+ Whenever you create a mesocycle with an exercise split, that split is actually cloned for that mesocycle. This + allows you and the app to make changes to the mesocycle's split without altering the original split. +

+ +

"I need more help!"

+

+ Feel free to open an issue on the GitHub repository, will be glad + to help you out and add more details to the docs +

+
diff --git a/src/routes/privacy-policy/+page.svelte b/src/routes/privacy-policy/+page.svelte index 9704d009..b262c1ca 100644 --- a/src/routes/privacy-policy/+page.svelte +++ b/src/routes/privacy-policy/+page.svelte @@ -89,9 +89,7 @@
  • Website refers to MyFit, accessible from - https://my-fit-whyash5114.vercel.app + https://my-fit-v3.vercel.app