mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 12:06:44 +00:00
Display some basic stats
This commit is contained in:
parent
aa210efad6
commit
244d364575
@ -45,6 +45,7 @@ function inventreeDocReady() {
|
|||||||
// Callback to launch the 'Database Stats' window
|
// Callback to launch the 'Database Stats' window
|
||||||
$('#launch-stats').click(function() {
|
$('#launch-stats').click(function() {
|
||||||
launchModalForm("/stats/", {
|
launchModalForm("/stats/", {
|
||||||
|
no_post: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,8 @@ from django.views import View
|
|||||||
from django.views.generic import UpdateView, CreateView
|
from django.views.generic import UpdateView, CreateView
|
||||||
from django.views.generic.base import TemplateView
|
from django.views.generic.base import TemplateView
|
||||||
|
|
||||||
from part.models import Part
|
from part.models import Part, PartCategory
|
||||||
|
from stock.models import StockLocation, StockItem
|
||||||
from common.models import InvenTreeSetting
|
from common.models import InvenTreeSetting
|
||||||
|
|
||||||
from .forms import DeleteForm, EditUserForm, SetPasswordForm
|
from .forms import DeleteForm, EditUserForm, SetPasswordForm
|
||||||
@ -544,4 +545,27 @@ class DatabaseStatsView(AjaxView):
|
|||||||
""" View for displaying database statistics """
|
""" View for displaying database statistics """
|
||||||
|
|
||||||
ajax_template_name = "stats.html"
|
ajax_template_name = "stats.html"
|
||||||
ajax_form_title = _("Database Statistics")
|
ajax_form_title = _("Database Statistics")
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
|
||||||
|
ctx = {}
|
||||||
|
|
||||||
|
# Part stats
|
||||||
|
ctx['part_count'] = Part.objects.count()
|
||||||
|
ctx['part_cat_count'] = PartCategory.objects.count()
|
||||||
|
|
||||||
|
# Stock stats
|
||||||
|
ctx['stock_item_count'] = StockItem.objects.count()
|
||||||
|
ctx['stock_loc_count'] = StockLocation.objects.count()
|
||||||
|
|
||||||
|
"""
|
||||||
|
TODO: Other ideas for database metrics
|
||||||
|
|
||||||
|
- "Popular" parts (used to make other parts?)
|
||||||
|
- Most ordered part
|
||||||
|
- Most sold part
|
||||||
|
- etc etc etc
|
||||||
|
"""
|
||||||
|
|
||||||
|
return ctx
|
@ -2,4 +2,27 @@
|
|||||||
{% load inventree_extras %}
|
{% load inventree_extras %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
HELLO WORLD
|
<table class='table table-striped table-condensed'>
|
||||||
|
<tr>
|
||||||
|
<td colspan='2'><b>{% trans "Parts" %}</b></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{% trans "Parts" %}</td>
|
||||||
|
<td>{{ part_count }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{% trans "Part Categories" %}</td>
|
||||||
|
<td>{{ part_cat_count }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><b>{% trans "Stock Items" %}</b></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{% trans "Stock Items" %}</td>
|
||||||
|
<td>{{ stock_item_count }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{% trans "Stock Locations" %}</td>
|
||||||
|
<td>{{ stock_loc_count }}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
Loading…
x
Reference in New Issue
Block a user