@runnerpro/backend 1.18.4 → 1.18.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/notion/index.js +1 -1
- package/lib/cjs/slack/index.js +1 -0
- package/lib/cjs/types/notion/index.d.ts +1 -1
- package/lib/cjs/types/slack/index.d.ts +1 -0
- package/lib/cjs/types/slack/index.d.ts.map +1 -1
- package/lib/cjs/types/workout/planificacionPrueba7dias/index.d.ts +19 -0
- package/lib/cjs/types/workout/planificacionPrueba7dias/index.d.ts.map +1 -1
- package/lib/cjs/workout/planificacionPrueba7dias/index.js +43 -15
- package/package.json +1 -1
package/lib/cjs/notion/index.js
CHANGED
|
@@ -19,7 +19,7 @@ Obtener ID de una BBDD de Notion
|
|
|
19
19
|
4º Arriba a la derecha en los 3 puntos horizontales -> Conexiones -> Conectar con API (logo de RunnerPro)
|
|
20
20
|
*/
|
|
21
21
|
const NOTION_DATABASES_ID = {
|
|
22
|
-
|
|
22
|
+
REGISTRADOS_PRUEBA_15_DIAS: '25732354-92bd-4bb5-8937-0ad583b795ab',
|
|
23
23
|
OBSERVAR_CLIENTE: '47fc4035-7028-41c2-8b81-8e91d44a989b',
|
|
24
24
|
BUSQUEDA_INFLUENCERS: 'a06bd20c-70b3-4962-a8b2-fb0e977e4530',
|
|
25
25
|
};
|
package/lib/cjs/slack/index.js
CHANGED
|
@@ -22,6 +22,7 @@ exports.notifySlack = notifySlack;
|
|
|
22
22
|
*/
|
|
23
23
|
const CHANNEL_SLACK = {
|
|
24
24
|
COACH: 'T05JCPFMXE0/B05UXA86WLS/RbuCBYuAnX6sedPttFQwkgbB',
|
|
25
|
+
COACH_LOGS: 'T05JCPFMXE0/B0AEP9THSFJ/x1ea4vRfUN63NHOPvBvombQB',
|
|
25
26
|
BRUTAL: 'T05JCPFMXE0/B05RDSHESGZ/lHGRox6UiOkioUMHQscap9pA',
|
|
26
27
|
TEST: 'T05JCPFMXE0/B0601LMECSW/RsTOfjgMrxCPIvHAIttjwIPj',
|
|
27
28
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/slack/index.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,WAAW;;;UAYhB,CAAC;AAQF,QAAA,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/slack/index.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,WAAW;;;UAYhB,CAAC;AAQF,QAAA,MAAM,aAAa;;;;;CAKlB,CAAC;AAEF,OAAO,EACL,WAAW,EACX,aAAa,GACd,CAAC"}
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Genera una planificación de prueba de 7 días para un cliente
|
|
3
|
+
*
|
|
4
|
+
* @param c - Objeto con los datos del cliente (días disponibles, objetivo, nivel, etc.)
|
|
5
|
+
* @param options - Opciones adicionales
|
|
6
|
+
* @param options.startDate - Fecha de inicio de la planificación (opcional, por defecto hoy)
|
|
7
|
+
* @returns Array de entrenamientos con fechas asignadas
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const planificacion = getPlanificacionPrueba7dias({
|
|
12
|
+
* monday: true,
|
|
13
|
+
* wednesday: true,
|
|
14
|
+
* saturday: true,
|
|
15
|
+
* goalDistance: 10000,
|
|
16
|
+
* nivelActual: 2,
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
1
20
|
declare const getPlanificacionPrueba7dias: (c: any, options?: any) => any[];
|
|
2
21
|
export { getPlanificacionPrueba7dias };
|
|
3
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/workout/planificacionPrueba7dias/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/workout/planificacionPrueba7dias/index.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;;;;;GAkBG;AACH,QAAA,MAAM,2BAA2B,qBAAgB,GAAG,UAkEnD,CAAC;AAmIF,OAAO,EAAE,2BAA2B,EAAE,CAAC"}
|
|
@@ -12,16 +12,35 @@ const getPlanificacionPrueba7dias42k_1 = require("./42k/getPlanificacionPrueba7d
|
|
|
12
12
|
const sendMail_1 = require("../../sendMail");
|
|
13
13
|
const moment_1 = __importDefault(require("moment"));
|
|
14
14
|
const common_1 = require("@runnerpro/common");
|
|
15
|
+
/**
|
|
16
|
+
* Genera una planificación de prueba de 7 días para un cliente
|
|
17
|
+
*
|
|
18
|
+
* @param c - Objeto con los datos del cliente (días disponibles, objetivo, nivel, etc.)
|
|
19
|
+
* @param options - Opciones adicionales
|
|
20
|
+
* @param options.startDate - Fecha de inicio de la planificación (opcional, por defecto hoy)
|
|
21
|
+
* @returns Array de entrenamientos con fechas asignadas
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const planificacion = getPlanificacionPrueba7dias({
|
|
26
|
+
* monday: true,
|
|
27
|
+
* wednesday: true,
|
|
28
|
+
* saturday: true,
|
|
29
|
+
* goalDistance: 10000,
|
|
30
|
+
* nivelActual: 2,
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
15
34
|
const getPlanificacionPrueba7dias = (c, options = {}) => {
|
|
16
35
|
const { startDate } = options;
|
|
17
|
-
const
|
|
18
|
-
const nDiasDisponibles =
|
|
19
|
-
let
|
|
36
|
+
const diasDisponiblesSemana = [!!c.sunday, !!c.monday, !!c.tuesday, !!c.wednesday, !!c.thursday, !!c.friday, !!c.saturday];
|
|
37
|
+
const nDiasDisponibles = diasDisponiblesSemana.filter((d) => d).length;
|
|
38
|
+
let workoutsBase = [];
|
|
20
39
|
changeGoalDistanceByNivelActual(c);
|
|
21
40
|
// @ts-ignore
|
|
22
|
-
|
|
23
|
-
if (!
|
|
24
|
-
|
|
41
|
+
workoutsBase = getWorkoutsByGoalDistance(c);
|
|
42
|
+
if (!workoutsBase || workoutsBase.length === 0) {
|
|
43
|
+
workoutsBase = [];
|
|
25
44
|
(0, sendMail_1.sendMail)({
|
|
26
45
|
to: ['david.jimenez@runnerpro.app'],
|
|
27
46
|
subject: 'Planificación de prueba 7 días - No hay entrenamientos',
|
|
@@ -31,10 +50,12 @@ const getPlanificacionPrueba7dias = (c, options = {}) => {
|
|
|
31
50
|
}
|
|
32
51
|
if ((Number(c.nivelEntrenamientoFuerza) === 1 || Number(c.incluirEntrenamientoFuerza) === 1) && nDiasDisponibles >= 4) {
|
|
33
52
|
// @ts-ignore
|
|
34
|
-
|
|
53
|
+
workoutsBase.splice(1, 0, addWorkoutFuerza());
|
|
35
54
|
}
|
|
36
|
-
|
|
37
|
-
|
|
55
|
+
// Ajustar días disponibles si hay más días que entrenamientos en una semana
|
|
56
|
+
const diasDisponibles = [...diasDisponiblesSemana];
|
|
57
|
+
if (nDiasDisponibles > workoutsBase.length) {
|
|
58
|
+
const nDiasExtra = nDiasDisponibles - workoutsBase.length;
|
|
38
59
|
for (let i = 0; i < nDiasExtra; i++) {
|
|
39
60
|
if (diasDisponibles[0] && diasDisponibles[1])
|
|
40
61
|
diasDisponibles[1] = false;
|
|
@@ -53,18 +74,25 @@ const getPlanificacionPrueba7dias = (c, options = {}) => {
|
|
|
53
74
|
}
|
|
54
75
|
}
|
|
55
76
|
const planificacion = [];
|
|
56
|
-
// Add workouts to planificacion array based on diasDisponibles and taking into account today day of week and adding to workout the date
|
|
57
77
|
const today = startDate ? (0, moment_1.default)(startDate) : (0, moment_1.default)();
|
|
58
78
|
const todayDayOfWeek = today.day();
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
79
|
+
const diasAGenerar = 7;
|
|
80
|
+
// Índice para iterar sobre los workouts de forma cíclica
|
|
81
|
+
let workoutIndex = 0;
|
|
82
|
+
// Iterar sobre los días a generar
|
|
83
|
+
for (let i = 0; i < diasAGenerar; i++) {
|
|
84
|
+
const dayIndex = (todayDayOfWeek + i) % 7;
|
|
85
|
+
if (diasDisponibles[dayIndex]) {
|
|
86
|
+
// Si se acabaron los workouts, reiniciar desde el principio (repetición cíclica)
|
|
87
|
+
if (workoutIndex >= workoutsBase.length) {
|
|
88
|
+
workoutIndex = 0;
|
|
89
|
+
}
|
|
90
|
+
const workout = workoutsBase[workoutIndex];
|
|
63
91
|
const date = (0, moment_1.default)(today).add(i, 'days').format('YYYY-MM-DD');
|
|
64
92
|
// @ts-ignore
|
|
65
93
|
planificacion.push(Object.assign(Object.assign({}, workout), { date }));
|
|
94
|
+
workoutIndex++;
|
|
66
95
|
}
|
|
67
|
-
todayIndex = (todayIndex + 1) % 7;
|
|
68
96
|
}
|
|
69
97
|
return planificacion;
|
|
70
98
|
};
|