Change date format and order list of users by age of account
This commit is contained in:
6
db.py
6
db.py
@@ -1,7 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
import psycopg2
|
import psycopg2
|
||||||
from psycopg2.extras import RealDictCursor
|
from psycopg2.extras import RealDictCursor
|
||||||
import datetime
|
from datetime import datetime
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from utils import get_all_exercises_from_topsets, get_people_and_exercise_rep_maxes, get_workouts
|
from utils import get_all_exercises_from_topsets, get_people_and_exercise_rep_maxes, get_workouts
|
||||||
@@ -120,6 +120,8 @@ class DataBase():
|
|||||||
FROM
|
FROM
|
||||||
Person P LEFT JOIN Workout W ON P.PersonId = W.PersonId
|
Person P LEFT JOIN Workout W ON P.PersonId = W.PersonId
|
||||||
GROUP BY
|
GROUP BY
|
||||||
|
P.PersonId
|
||||||
|
ORDER BY
|
||||||
P.PersonId""", [person_id])
|
P.PersonId""", [person_id])
|
||||||
|
|
||||||
def get_person_final(self, person_id):
|
def get_person_final(self, person_id):
|
||||||
@@ -170,7 +172,7 @@ class DataBase():
|
|||||||
'PersonId': next((t['PersonId'] for t in topsets), -1),
|
'PersonId': next((t['PersonId'] for t in topsets), -1),
|
||||||
'PersonName': next((t['PersonName'] for t in topsets), 'Unknown'),
|
'PersonName': next((t['PersonName'] for t in topsets), 'Unknown'),
|
||||||
'WorkoutId': workout_id,
|
'WorkoutId': workout_id,
|
||||||
'StartDate': next((t['StartDate'] for t in topsets), 'Unknown'),
|
'StartDate': datetime.strptime(topsets[0]['StartDate'], "%Y-%m-%d").strftime("%b %d %Y"),
|
||||||
'Exercises': self.get_exercises(),
|
'Exercises': self.get_exercises(),
|
||||||
'TopSets': [{"TopSetId": t['TopSetId'], "ExerciseId": t['ExerciseId'], "ExerciseName": t['ExerciseName'], "Weight": t['Weight'], "Repetitions": t['Repetitions']} for t in topsets if t['TopSetId'] is not None]
|
'TopSets': [{"TopSetId": t['TopSetId'], "ExerciseId": t['ExerciseId'], "ExerciseName": t['ExerciseName'], "Weight": t['Weight'], "Repetitions": t['Repetitions']} for t in topsets if t['TopSetId'] is not None]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,10 @@
|
|||||||
<script src="https://cdn.tailwindcss.com"></script>
|
<script src="https://cdn.tailwindcss.com"></script>
|
||||||
<script src="https://cdn.plot.ly/plotly-2.14.0.min.js"></script>
|
<script src="https://cdn.plot.ly/plotly-2.14.0.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
window.addEventListener('resize', function () {
|
let doit;
|
||||||
window.dispatchEvent(new Event('resize'));
|
window.addEventListener('resize', () => {
|
||||||
|
clearTimeout(doit);
|
||||||
|
doit = setTimeout(window.dispatchEvent(new Event('resize')), 100);
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
x: {{ e['EstimatedOneRepMaxProgressions']['StartDates'] | replace('"', "'") | safe }},
|
x: {{ e['EstimatedOneRepMaxProgressions']['StartDates'] | replace('"', "'") | safe }},
|
||||||
y: {{ e['EstimatedOneRepMaxProgressions']['Estimated1RMs'] | replace('"', "'") | safe }},
|
y: {{ e['EstimatedOneRepMaxProgressions']['Estimated1RMs'] | replace('"', "'") | safe }},
|
||||||
text: {{ e['EstimatedOneRepMaxProgressions']['TopSets'] | replace('"', "'") | safe }},
|
text: {{ e['EstimatedOneRepMaxProgressions']['TopSets'] | replace('"', "'") | safe }},
|
||||||
|
name: "{{ p['PersonName'] }} - {{ e['ExerciseName'] }}",
|
||||||
hovertemplate
|
hovertemplate
|
||||||
}], layout, config);
|
}], layout, config);
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
4
utils.py
4
utils.py
@@ -14,7 +14,7 @@ def get_workouts(topsets):
|
|||||||
t for t in topsets if t['WorkoutId'] == workout_id]
|
t for t in topsets if t['WorkoutId'] == workout_id]
|
||||||
workouts.append({
|
workouts.append({
|
||||||
'WorkoutId': workout_id,
|
'WorkoutId': workout_id,
|
||||||
'StartDate': topsets_in_workout[0]['StartDate'],
|
'StartDate': datetime.strptime(topsets_in_workout[0]['StartDate'], "%Y-%m-%d").strftime("%b %d %Y"),
|
||||||
'TopSets': [{"TopSetId": t['TopSetId'], "ExerciseId": t['ExerciseId'], "ExerciseName": t['ExerciseName'], "Weight": t['Weight'], "Repetitions": t['Repetitions']} for t in topsets_in_workout]
|
'TopSets': [{"TopSetId": t['TopSetId'], "ExerciseId": t['ExerciseId'], "ExerciseName": t['ExerciseName'], "Weight": t['Weight'], "Repetitions": t['Repetitions']} for t in topsets_in_workout]
|
||||||
})
|
})
|
||||||
return workouts
|
return workouts
|
||||||
@@ -47,7 +47,7 @@ def get_rep_maxes_for_person(person_topsets):
|
|||||||
max_weight = max([t['Weight'] for t in reps])
|
max_weight = max([t['Weight'] for t in reps])
|
||||||
max_topset_for_rep = [t for t in reps if t['Weight'] == max_weight]
|
max_topset_for_rep = [t for t in reps if t['Weight'] == max_weight]
|
||||||
topsets_for_exercise.append({
|
topsets_for_exercise.append({
|
||||||
'StartDate': max_topset_for_rep[0]['StartDate'],
|
'StartDate': datetime.strptime(max_topset_for_rep[0]['StartDate'], "%Y-%m-%d").strftime("%b %d %Y"),
|
||||||
'Repetitions': rep,
|
'Repetitions': rep,
|
||||||
'Weight': max_weight,
|
'Weight': max_weight,
|
||||||
'Estimated1RM': max_topset_for_rep[0]['Estimated1RM'],
|
'Estimated1RM': max_topset_for_rep[0]['Estimated1RM'],
|
||||||
|
|||||||
Reference in New Issue
Block a user