Fix tags, may have increased load on database while only using one query to fetch workout, topsets, and all tags

This commit is contained in:
Peter Stockings
2024-11-04 22:33:08 +11:00
parent 10326ccd7a
commit b5493e627c
6 changed files with 48 additions and 33 deletions

View File

@@ -1,7 +1,6 @@
<div class="flex">
<div id="tag-wrapper-w-{{ workout_id }}">
{{ render_partial('partials/workout_tags_list.html', workout_tags=workout_tags)
}}
{{ render_partial('partials/workout_tags_list.html', tags=tags)}}
</div>
<span id="tag-form-show-w-{{ workout_id }}" class="cursor-pointer" _="on click
remove .hidden from #tag-form-w-{{ workout_id }}
@@ -23,7 +22,7 @@
</span>
</div>
<div id="tag-form-w-{{ workout_id }}" class="hidden pt-2 pb-3 animate-fadeIn">
<div id="tag-form-w-{{ workout_id }}" class="hidden pt-2 pb-3">
<span class="text-base font-normal text-gray-500">Add tag to workout</span>
@@ -46,10 +45,10 @@
placeholder: 'Select tags',
})
end">
{% for p in person_tags %}
<option value="{{ p.tag_id }}" {% if p.tag_id in selected_workout_tag_ids %}selected{% endif %}>
{% for tag in tags %}
<option value="{{ tag.tag_id }}" {% if tag.is_selected %}selected{% endif %}>
{{
p.tag_name
tag.tag_name
}}</option>
{% endfor %}
</select>

View File

@@ -1,8 +1,10 @@
{% for tag in workout_tags %}
{% for tag in tags %}
{% if tag.is_selected %}
<span
class="text-xs font-semibold inline-block py-1 px-2 uppercase rounded text-pink-600 bg-pink-200 uppercase last:mr-0 mr-1 max-h-fit cursor-pointer"
hx-get="{{ url_for('goto_tag') }}" hx-vals='{"filter": "{{ tag.tag_filter }}", "person_id": "{{ tag.person_id }}"}'
hx-target="#container" hx-push-url="true" _='on click trigger closeModalWithoutRefresh'>{{
hx-target="#container" hx-push-url="true">{{
tag.tag_name }}
</span>
{% endif %}
{% endfor%}

View File

@@ -13,10 +13,8 @@
<div class="w-full">
<h3 class="text-xl font-bold text-gray-900">{{ person_name }}</h3>
{{ render_partial('partials/workout_tags.html', person_id=person_id,
workout_id=workout_id,
person_tags=person_tags, workout_tags=workout_tags,
selected_workout_tag_ids=selected_workout_tag_ids) }}
{{ render_partial('partials/workout_tags.html', person_id=person_id, workout_id=workout_id,
tags=tags) }}
</div>