summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Reichel <sre@ring0.de>2012-07-27 02:16:37 +0200
committerSebastian Reichel <sre@ring0.de>2012-07-27 02:16:37 +0200
commit298a58b55028a2901ea04817f72e2d9218c258a4 (patch)
tree89f39d0319c724a55342064ca13d215ff3feeb83
parentf07de9c031d7612b8ca656c34ebce57f6856b6b2 (diff)
downloadktt-inventory-system-298a58b55028a2901ea04817f72e2d9218c258a4.tar.bz2
blame item with most attached barcodes
-rw-r--r--inventar/templates/stats.html9
-rw-r--r--inventory/views.py1
2 files changed, 6 insertions, 4 deletions
diff --git a/inventar/templates/stats.html b/inventar/templates/stats.html
index 10829a7..32444f1 100644
--- a/inventar/templates/stats.html
+++ b/inventar/templates/stats.html
@@ -5,12 +5,13 @@
<h2>Statistics:</h2>
<ul>
- <li>Number of codes: {{ number_of_codes }}
+ <li>Number of codes: {{ number_of_codes }}</li>
<li>Number of items: {{ number_of_items }}
<ul>
- <li>with parent: {{ number_of_items_with_parent }}
- <li>without parent: {{ number_of_items_without_parent }}
- </ul>
+ <li>with parent: {{ number_of_items_with_parent }}</li>
+ <li>without parent: {{ number_of_items_without_parent }}</li>
+ </ul></li>
+ <li>Item with most barcodes: {{ max_barcodes_item.name }} [<b>{{max_barcodes_item.number_of_attached_barcodes}}</b> Barcodes]</li>
</ul>
Work in Progress...
diff --git a/inventory/views.py b/inventory/views.py
index 9f20d06..43ea76d 100644
--- a/inventory/views.py
+++ b/inventory/views.py
@@ -78,4 +78,5 @@ def stats(request):
"number_of_items": models.Item.objects.count(),
"number_of_items_with_parent": models.Item.objects.filter(parent__isnull=False).count(),
"number_of_items_without_parent": models.Item.objects.filter(parent__isnull=True).count(),
+ "max_barcodes_item": models.Item.objects.raw('SELECT inventory_item.*, COUNT(inventory_barcode.item_id) AS number_of_attached_barcodes FROM inventory_item INNER JOIN inventory_barcode ON inventory_barcode.item_id = inventory_item.id GROUP BY inventory_barcode.item_id ORDER BY COUNT(inventory_barcode.item_id) DESC LIMIT 1;')[0],
})