onaio / mspray

Mspray
https://mspray.onalabs.org/
Apache License 2.0
3 stars 1 forks source link

Use generator expressions in performance.py and add tests #483

Closed moshthepitt closed 5 years ago

moshthepitt commented 6 years ago

Currently the mspray.apps.main.views.performance module does, among other things, calculations such that look like:

"not_sprayed_total": sum(
                [i["not_sprayed_total"] for i in serializer.data]
            )

See https://github.com/onaio/mspray/blob/master/mspray/apps/main/views/performance.py#L118 for an example.

We can make this a little better by using generator expressions instead of list comprehensions in order to get the sum(s).

Additionally, once this is done we should add tests for those parts of the code that we change.

moshthepitt commented 5 years ago

Fixed by #488