Instead of retreiving list of users and workouts card on initial load which involves a second db call, use htmx onload callback
This commit is contained in:
6
app.py
6
app.py
@@ -472,10 +472,6 @@ def my_utility_processor():
|
||||
return 'bg-gray-200'
|
||||
return ''
|
||||
|
||||
def get_list_of_people_and_workout_count():
|
||||
person_id = request.view_args.get('person_id')
|
||||
return db.get_people_and_workout_count(person_id)
|
||||
|
||||
def get_first_element_from_list_with_matching_attribute(list, attribute, value):
|
||||
if not list:
|
||||
return None
|
||||
@@ -495,7 +491,7 @@ def my_utility_processor():
|
||||
def list_to_string(list):
|
||||
return [str(i) for i in list]
|
||||
|
||||
return dict(get_list_of_people_and_workout_count=get_list_of_people_and_workout_count, is_selected_page=is_selected_page, get_first_element_from_list_with_matching_attribute=get_first_element_from_list_with_matching_attribute, in_list=in_list, strftime=strftime, datetime=datetime, timedelta=timedelta, relativedelta=relativedelta, first_and_last_visible_days_in_month=first_and_last_visible_days_in_month, list_to_string=list_to_string, quote=quote)
|
||||
return dict(is_selected_page=is_selected_page, get_first_element_from_list_with_matching_attribute=get_first_element_from_list_with_matching_attribute, in_list=in_list, strftime=strftime, datetime=datetime, timedelta=timedelta, relativedelta=relativedelta, first_and_last_visible_days_in_month=first_and_last_visible_days_in_month, list_to_string=list_to_string, quote=quote)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -79,10 +79,7 @@
|
||||
</a>
|
||||
</div>
|
||||
<ul class="space-y-2 pb-2" hx-get="{{ url_for('get_person_list') }}"
|
||||
hx-trigger="updatedPeople from:body">
|
||||
{{ render_partial('partials/people_link.html',
|
||||
people=get_list_of_people_and_workout_count()) }}
|
||||
|
||||
hx-trigger="load, updatedPeople from:body">
|
||||
</ul>
|
||||
<div class="space-y-2 pt-2">
|
||||
<a hx-get="{{ url_for('settings') }}" hx-push-url="true" hx-target="#container"
|
||||
|
||||
Reference in New Issue
Block a user