diff --git a/docs/changelog.rst b/docs/changelog.rst index 760738258..2b5110107 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -7,6 +7,7 @@ v1.3.1 - 2016-xx-xx - CSS large margin-bottom (`#144 `_). - Django security releases issued: 1.8.14 (`#147 `_). - Requirements update (August 2016) (`#148 `_). +- Query performance improvements (`#149 `_). v1.3.0 - 2016-07-15 diff --git a/dsmr_consumption/migrations/0003_electricity_consumption_indexes.py b/dsmr_consumption/migrations/0003_electricity_consumption_indexes.py new file mode 100644 index 000000000..26accb86f --- /dev/null +++ b/dsmr_consumption/migrations/0003_electricity_consumption_indexes.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('dsmr_consumption', '0002_verbose_text'), + ] + + operations = [ + migrations.AlterField( + model_name='electricityconsumption', + name='currently_delivered', + field=models.DecimalField(decimal_places=3, help_text='Actual electricity power delivered (+P) in 1 Watt resolution', db_index=True, max_digits=9), + ), + migrations.AlterField( + model_name='electricityconsumption', + name='currently_returned', + field=models.DecimalField(decimal_places=3, help_text='Actual electricity power received (-P) in 1 Watt resolution', db_index=True, max_digits=9), + ), + ] diff --git a/dsmr_consumption/models/consumption.py b/dsmr_consumption/models/consumption.py index a24c91132..dc4c78ac6 100644 --- a/dsmr_consumption/models/consumption.py +++ b/dsmr_consumption/models/consumption.py @@ -28,12 +28,14 @@ class ElectricityConsumption(models.Model): currently_delivered = models.DecimalField( max_digits=9, decimal_places=3, - help_text=_("Actual electricity power delivered (+P) in 1 Watt resolution") + help_text=_("Actual electricity power delivered (+P) in 1 Watt resolution"), + db_index=True ) currently_returned = models.DecimalField( max_digits=9, decimal_places=3, - help_text=_("Actual electricity power received (-P) in 1 Watt resolution") + help_text=_("Actual electricity power received (-P) in 1 Watt resolution"), + db_index=True ) def __str__(self): diff --git a/dsmrreader/__init__.py b/dsmrreader/__init__.py index a94113834..c1e4d901e 100644 --- a/dsmrreader/__init__.py +++ b/dsmrreader/__init__.py @@ -17,6 +17,6 @@ from django.utils.version import get_version -VERSION = (1, 3, 1, 'beta', 3) +VERSION = (1, 3, 1, 'beta', 4) __version__ = get_version(VERSION) diff --git a/dsmrreader/config/development.py b/dsmrreader/config/development.py index 083f19377..e70bc3007 100644 --- a/dsmrreader/config/development.py +++ b/dsmrreader/config/development.py @@ -22,3 +22,12 @@ }, }, } + +INSTALLED_APPS = list(INSTALLED_APPS) +INSTALLED_APPS.append('debug_toolbar') + +DEBUG_TOOLBAR_PATCH_SETTINGS = False + +MIDDLEWARE_CLASSES = list(MIDDLEWARE_CLASSES) +MIDDLEWARE_CLASSES.insert(0, 'debug_toolbar.middleware.DebugToolbarMiddleware') +INTERNAL_IPS = '127.0.0.1' diff --git a/dsmrreader/config/test.py b/dsmrreader/config/test.py index 96fad2141..be5cb5563 100644 --- a/dsmrreader/config/test.py +++ b/dsmrreader/config/test.py @@ -18,6 +18,13 @@ # Only available (and required) for tests, so inject it here. INSTALLED_APPS = list(INSTALLED_APPS) INSTALLED_APPS.append('django_nose') +INSTALLED_APPS.remove('debug_toolbar') + +# Disable DDT. +MIDDLEWARE_CLASSES = list(MIDDLEWARE_CLASSES) +MIDDLEWARE_CLASSES.remove('debug_toolbar.middleware.DebugToolbarMiddleware') + +INTERNAL_IPS = None TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' NOSE_ARGS = [ diff --git a/dsmrreader/locales/nl/LC_MESSAGES/django.mo b/dsmrreader/locales/nl/LC_MESSAGES/django.mo index c3f995d9b..ec61c229b 100644 Binary files a/dsmrreader/locales/nl/LC_MESSAGES/django.mo and b/dsmrreader/locales/nl/LC_MESSAGES/django.mo differ diff --git a/dsmrreader/locales/nl/LC_MESSAGES/django.po b/dsmrreader/locales/nl/LC_MESSAGES/django.po index 538adc004..588f6eca1 100644 --- a/dsmrreader/locales/nl/LC_MESSAGES/django.po +++ b/dsmrreader/locales/nl/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: DSMR Reader\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-08-15 20:55+0200\n" +"POT-Creation-Date: 2016-08-15 22:55+0200\n" "PO-Revision-Date: 2016-07-13 22:58+0100\n" "Last-Translator: Dennis Siemensma \n" "Language-Team: Dennis Siemensma \n" diff --git a/dsmrreader/provisioning/requirements/dev.txt b/dsmrreader/provisioning/requirements/dev.txt index a86aa1882..507875ff5 100644 --- a/dsmrreader/provisioning/requirements/dev.txt +++ b/dsmrreader/provisioning/requirements/dev.txt @@ -1,3 +1,4 @@ +django-debug-toolbar==1.5 Sphinx==1.4.5 sphinx-autobuild==0.6.0 sphinx-intl==0.9.9 diff --git a/dsmrreader/urls.py b/dsmrreader/urls.py index d2e2864ad..fe9572dcf 100644 --- a/dsmrreader/urls.py +++ b/dsmrreader/urls.py @@ -15,9 +15,18 @@ """ from django.conf.urls import include, url from django.contrib import admin +from django.conf import settings + urlpatterns = [ url(r'^admin/', include(admin.site.urls)), url(r'^api/v1/', include('dsmr_api.urls', namespace='api')), url(r'^', include('dsmr_frontend.urls', namespace='frontend')), ] + +if settings.DEBUG: + import debug_toolbar + + urlpatterns += [ + url(r'^__debug__/', include(debug_toolbar.urls)), + ]