Skip to content

Commit

Permalink
Merge branch '125-trends-no-data-error' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
dennissiemensma committed May 1, 2016
2 parents c1c57c2 + f2cbbd9 commit fc4592b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![Build Status](https://travis-ci.org/dennissiemensma/dsmr-reader.svg?branch=master)](https://travis-ci.org/dennissiemensma/dsmr-reader)
[![Coverage](https://codecov.io/github/dennissiemensma/dsmr-reader/coverage.svg?branch=master)](https://codecov.io/github/dennissiemensma/dsmr-reader?branch=master)
[![Requirements Status](https://requires.io/github/dennissiemensma/dsmr-reader/requirements.svg?branch=master)](https://requires.io/github/dennissiemensma/dsmr-reader/requirements/?branch=master)
[![Documentation Status](http://readthedocs.org/projects/dsmr-reader/badge/?version=latest)](http://dsmr-reader.readthedocs.org/en/latest/?badge=latest)
[![Documentation Status](http://readthedocs.org/projects/dsmr-reader/badge/?version=latest)](http://dsmr-reader.readthedocs.io/en/latest/?badge=latest)


# About
Expand All @@ -12,15 +12,15 @@ There are plenty of ‘scripts’ and websites available for performing DSMR rea

**English**

See [Read The Docs, in English](http://dsmr-reader.readthedocs.org/en/latest/). Installation guide can be found there as well.
See [Read The Docs, in English](http://dsmr-reader.readthedocs.io/en/latest/). Installation guide can be found there as well.

**Dutch / Nederlands**

Zie [Read The Docs, in het Nederlands](http://dsmr-reader.readthedocs.org/nl/latest/). Je kunt daar ook alle installatieinstructies vinden.
Zie [Read The Docs, in het Nederlands](http://dsmr-reader.readthedocs.io/nl/latest/). Je kunt daar ook alle installatieinstructies vinden.


# Screenshots
More screenshots can be found in the documentation at [Read The Docs](http://dsmr-reader.readthedocs.org/en/latest/screenshots.html).
More screenshots can be found in the documentation at [Read The Docs](http://dsmr-reader.readthedocs.io/en/latest/screenshots.html).

## Dashboard
![Dashboard](docs/_static/screenshots/dashboard.png)
Expand Down
2 changes: 1 addition & 1 deletion dsmr_frontend/templates/dsmr_frontend/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
{% block header_right %}{% endblock %}

<li>
<a href="http://dsmr-reader.readthedocs.org/{{ LANGUAGE_CODE }}/latest/changelog.html" target="_blank" title="{% trans 'View releases' %}">
<a href="http://dsmr-reader.readthedocs.io/{{ LANGUAGE_CODE }}/latest/changelog.html" target="_blank" title="{% trans 'View releases' %}">
<small>v{{ dsmr_version }}</small>
</a>
</li>
Expand Down
4 changes: 2 additions & 2 deletions dsmr_frontend/templates/dsmr_frontend/status.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
<table class="table table-condensed">
<tr>
<td class="col-md-6">{% trans "Current version" %} {% trans "DSMR-reader" %}</td>
<td class="col-md-6"><a href="https://github.com/dennissiemensma/dsmr-reader/releases/tag/v{{ dsmr_version }}" target="_blank" title="{% trans 'View current release' %}">v{{ dsmr_version }}</a></td>
<td class="col-md-6"><a href="https://github.com/dennissiemensma/dsmr-reader/releases/" target="_blank" title="{% trans 'View releases' %}">v{{ dsmr_version }}</a></td>
</tr>
<tr>
<td class="col-md-6">{% trans "Changelog" %}</td>
<td class="col-md-6"><a href="http://dsmr-reader.readthedocs.org/{{ LANGUAGE_CODE }}/latest/changelog.html" target="_blank">{% trans 'View all releases' %}</a></td>
<td class="col-md-6"><a href="http://dsmr-reader.readthedocs.io/{{ LANGUAGE_CODE }}/latest/changelog.html" target="_blank">{% trans 'View all releases' %}</a></td>
</tr>
</table>
</div><!-- /.panel-body -->
Expand Down
5 changes: 5 additions & 0 deletions dsmr_stats/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ def electricity_tariff_percentage(start_date):
electricity1=Sum('electricity1'),
electricity2=Sum('electricity2'),
)

# Empty data will crash.
if not all(totals.values()):
return None

global_total = totals['electricity1'] + totals['electricity2']
totals['electricity1'] = math.ceil(totals['electricity1'] / global_total * 100)
totals['electricity2'] = 100 - totals['electricity1']
Expand Down
4 changes: 4 additions & 0 deletions dsmr_stats/tests/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ def test_electricity_tariff_percentage(self):
self.assertEqual(percentages['electricity1'], 25)
self.assertEqual(percentages['electricity2'], 75)

# Now try again without data.
DayStatistics.objects.all().delete()
percentages = dsmr_stats.services.electricity_tariff_percentage(start_date=target_date.date())


class TestServicesWithoutGas(TestServices):
fixtures = ['dsmr_stats/electricity-consumption.json']

0 comments on commit fc4592b

Please sign in to comment.