From 0d89574a659ff1baeedae0a73a9b306fbd68bfb9 Mon Sep 17 00:00:00 2001 From: bugbountyguy Date: Mon, 4 Apr 2022 10:40:25 -0500 Subject: [PATCH] Fix lint issues --- core/migrations/0021_pumping.py | 41 ++++++++++++++++++++++--------- reports/graphs/pumping_amounts.py | 20 +++++++++------ 2 files changed, 42 insertions(+), 19 deletions(-) diff --git a/core/migrations/0021_pumping.py b/core/migrations/0021_pumping.py index 15448529..1c34a628 100644 --- a/core/migrations/0021_pumping.py +++ b/core/migrations/0021_pumping.py @@ -7,24 +7,43 @@ import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ - ('core', '0020_bmi_tags_diaperchange_tags_feeding_tags_and_more'), + ("core", "0020_bmi_tags_diaperchange_tags_feeding_tags_and_more"), ] operations = [ migrations.CreateModel( - name='Pumping', + name="Pumping", fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('amount', models.FloatField(verbose_name='Amount')), - ('time', models.DateTimeField(verbose_name='Time')), - ('notes', models.TextField(blank=True, null=True, verbose_name='Notes')), - ('child', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='pumping', to='core.child', verbose_name='Child')), + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("amount", models.FloatField(verbose_name="Amount")), + ("time", models.DateTimeField(verbose_name="Time")), + ( + "notes", + models.TextField(blank=True, null=True, verbose_name="Notes"), + ), + ( + "child", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="pumping", + to="core.child", + verbose_name="Child", + ), + ), ], options={ - 'verbose_name': 'Pumping', - 'verbose_name_plural': 'Pumping', - 'ordering': ['-time'], - 'default_permissions': ('view', 'add', 'change', 'delete'), + "verbose_name": "Pumping", + "verbose_name_plural": "Pumping", + "ordering": ["-time"], + "default_permissions": ("view", "add", "change", "delete"), }, ), ] diff --git a/reports/graphs/pumping_amounts.py b/reports/graphs/pumping_amounts.py index 9ea42fa3..ff160ab9 100644 --- a/reports/graphs/pumping_amounts.py +++ b/reports/graphs/pumping_amounts.py @@ -17,7 +17,7 @@ def pumping_amounts(objects): objects = objects.order_by("time") # We need to find date totals for annotations at the end - curr_date = '' + curr_date = "" date_totals = {} for object in objects: date_s = str(object.time.date()) @@ -26,9 +26,9 @@ def pumping_amounts(objects): curr_date = date_s date_totals[date_s] += object.amount - dates = [] # Single array for each bar - amounts = [] # Array of arrays containing amounts - index_x, index_y = 0,-1 + dates = [] # Single array for each bar + amounts = [] # Array of arrays containing amounts + index_x, index_y = 0, -1 for object in objects: date_s = str(object.time.date()) if date_s not in dates: @@ -36,12 +36,12 @@ def pumping_amounts(objects): index_y += 1 index_x = 0 if len(amounts) == 0 or len(amounts) <= index_x: - amounts.append([0]*len(date_totals.keys())) + amounts.append([0] * len(date_totals.keys())) amounts[index_x][index_y] = object.amount index_x += 1 - + traces = [] - for i in range(0, len(amounts)-1): + for i in range(0, len(amounts) - 1): traces.append( go.Bar( name="Amount", @@ -59,7 +59,11 @@ def pumping_amounts(objects): layout_args["xaxis"]["rangeselector"] = utils.rangeselector_date() layout_args["yaxis"]["title"] = _("Pumping Amount") - total_labels = [{"x": x, "y": total*1.1, "text": str(total), "showarrow": False} for x, total in zip(list(dates), date_totals.values())] + total_labels = [ + {"x": x, "y": total * 1.1, "text": str(total), "showarrow": False} + for x, total in zip(list(dates), date_totals.values()) + ] + fig = go.Figure({"data": traces, "layout": go.Layout(**layout_args)}) fig.update_layout(barmode="stack", annotations=total_labels) output = plotly.plot(fig, output_type="div", include_plotlyjs=False)