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) }}