From 7999572cf1d4e8a8becfe4e8b1490a27aa879757 Mon Sep 17 00:00:00 2001 From: Gregoo Date: Fri, 17 Jan 2025 16:28:43 +0100 Subject: [PATCH] Fix missing 'missing' and 'quantity' badges for minifigure in a part card --- bricktracker/sql/minifigure/list/missing_part.sql | 15 +++++++++++++++ bricktracker/sql/minifigure/list/using_part.sql | 9 +++++++++ templates/minifigure/card.html | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/bricktracker/sql/minifigure/list/missing_part.sql b/bricktracker/sql/minifigure/list/missing_part.sql index 5616ca9..99eee8f 100644 --- a/bricktracker/sql/minifigure/list/missing_part.sql +++ b/bricktracker/sql/minifigure/list/missing_part.sql @@ -1,5 +1,15 @@ {% extends 'minifigure/base/select.sql' %} +{% block total_missing %} +SUM(IFNULL(missing.quantity, 0)) AS total_missing, +{% endblock %} + +{% block join %} +LEFT JOIN missing +ON minifigures.fig_num IS NOT DISTINCT FROM missing.set_num +AND minifigures.u_id IS NOT DISTINCT FROM missing.u_id +{% endblock %} + {% block where %} WHERE minifigures.fig_num IN ( SELECT @@ -13,3 +23,8 @@ WHERE minifigures.fig_num IN ( GROUP BY missing.set_num ) {% endblock %} + +{% block group %} +GROUP BY + minifigures.fig_num +{% endblock %} diff --git a/bricktracker/sql/minifigure/list/using_part.sql b/bricktracker/sql/minifigure/list/using_part.sql index 4cca817..9b6b82c 100644 --- a/bricktracker/sql/minifigure/list/using_part.sql +++ b/bricktracker/sql/minifigure/list/using_part.sql @@ -1,5 +1,9 @@ {% extends 'minifigure/base/select.sql' %} +{% block total_quantity %} +SUM(minifigures.quantity) AS total_quantity, +{% endblock %} + {% block where %} WHERE minifigures.fig_num IN ( SELECT @@ -13,3 +17,8 @@ WHERE minifigures.fig_num IN ( GROUP BY inventory.set_num ) {% endblock %} + +{% block group %} +GROUP BY + minifigures.fig_num +{% endblock %} diff --git a/templates/minifigure/card.html b/templates/minifigure/card.html index 9b8172b..79ed414 100644 --- a/templates/minifigure/card.html +++ b/templates/minifigure/card.html @@ -10,8 +10,8 @@ {{ badge.set(item.fields.set_num, solo=solo, last=last, id=item.fields.u_id) }} {{ badge.quantity(item.fields.quantity, solo=solo, last=last) }} {% endif %} + {{ badge.quantity(item.fields.total_quantity, solo=solo, last=last) }} {{ badge.total_sets(using | length, solo=solo, last=last) }} - {{ badge.total_quantity(item.fields.total_quantity, solo=solo, last=last) }} {{ badge.total_missing(item.fields.total_missing, solo=solo, last=last) }} {% if not last %} {{ badge.rebrickable(item, solo=solo, last=last) }}