Skip to content

Commit 694cee2

Browse files
perryr16Ross Perrykflemin
authored
Display cycle name on report table (#5112)
display cycle on report table Co-authored-by: Ross Perry <ross.perry@Rosss-MacBook-Pro-2.local> Co-authored-by: Katherine Fleming <2205659+kflemin@users.noreply.github.com>
1 parent 0574640 commit 694cee2

File tree

3 files changed

+29
-20
lines changed

3 files changed

+29
-20
lines changed

seed/static/seed/partials/inventory_reports.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ <h4 class="chartTitle">{$ chart1Title | translate $}&nbsp;</h4>
327327
<table class="table">
328328
<thead>
329329
<tr>
330-
<th translate>Year Ending</th>
330+
<th translate>Cycle</th>
331331
<th translate>Properties with Data</th>
332332
<th translate>Total Properties</th>
333333
</tr>
@@ -339,7 +339,7 @@ <h4 class="chartTitle">{$ chart1Title | translate $}&nbsp;</h4>
339339
class="fa-solid fa-circle"
340340
style="color:{$ obj.color $}"
341341
></i
342-
>&nbsp;&nbsp;{$ obj.yr_e $}
342+
>&nbsp;&nbsp;{$ obj.cycle $}
343343
</td>
344344
<td>{$ obj['num_properties_w-data'] $}</td>
345345
<td>{$ obj.num_properties $}</td>
@@ -382,7 +382,7 @@ <h4 class="chartTitle">{$ chart2Title | translate $}&nbsp;</h4>
382382
<table class="table">
383383
<thead>
384384
<tr>
385-
<th translate>Year Ending</th>
385+
<th translate>Cycle</th>
386386
<th translate>Properties with Data</th>
387387
<th translate>Total Properties</th>
388388
</tr>
@@ -394,7 +394,7 @@ <h4 class="chartTitle">{$ chart2Title | translate $}&nbsp;</h4>
394394
class="fa-solid fa-square"
395395
style="color:{$ obj.color $}"
396396
></i
397-
>&nbsp;&nbsp;{$ obj.yr_e $}
397+
>&nbsp;&nbsp;{$ obj.cycle $}
398398
</td>
399399
<td>{$ obj['num_properties_w-data'] $}</td>
400400
<td>{$ obj.num_properties $}</td>

seed/tests/test_reports.py

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,18 @@ def test_report(self):
9494
"y_var": "gross_floor_area",
9595
}
9696
response = self.client.get(url, data)
97-
98-
assert response.json()["data"]["property_counts"] == [
99-
{"yr_e": "2016", "num_properties": 5, "num_properties_w-data": 5},
100-
{"yr_e": "2015", "num_properties": 5, "num_properties_w-data": 5},
97+
property_counts = response.json()["data"]["property_counts"]
98+
expected = [
99+
{"yr_e": "2016", "num_properties": 5, "num_properties_w-data": 5, "cycle": self.cycle_2.name},
100+
{"yr_e": "2015", "num_properties": 5, "num_properties_w-data": 5, "cycle": self.cycle.name},
101101
]
102+
self.assertEqual(property_counts, expected)
102103

103104
data["cycle_ids"] = [self.cycle.id]
104105
response = self.client.get(url, data)
105-
106-
assert response.json()["data"]["property_counts"] == [{"yr_e": "2015", "num_properties": 5, "num_properties_w-data": 5}]
106+
property_counts = response.json()["data"]["property_counts"]
107+
expected = [{"yr_e": "2015", "num_properties": 5, "num_properties_w-data": 5, "cycle": self.cycle.name}]
108+
self.assertEqual(property_counts, expected)
107109

108110
def test_report_aggregated(self):
109111
url = reverse("api:v3:organizations-report-aggregated", args=[self.org.pk])
@@ -114,15 +116,18 @@ def test_report_aggregated(self):
114116
"access_level_instance_id": self.org.root.id,
115117
}
116118
response = self.client.get(url, data)
117-
assert response.json()["aggregated_data"]["property_counts"] == [
118-
{"yr_e": "2016", "num_properties": 5, "num_properties_w-data": 5},
119-
{"yr_e": "2015", "num_properties": 5, "num_properties_w-data": 5},
119+
property_counts = response.json()["aggregated_data"]["property_counts"]
120+
expected = [
121+
{"yr_e": "2016", "num_properties": 5, "num_properties_w-data": 5, "cycle": self.cycle_2.name},
122+
{"yr_e": "2015", "num_properties": 5, "num_properties_w-data": 5, "cycle": self.cycle.name},
120123
]
124+
self.assertEqual(property_counts, expected)
121125

122126
data["cycle_ids"] = [self.cycle.id]
123127
response = self.client.get(url, data)
124-
125-
assert response.json()["aggregated_data"]["property_counts"] == [{"yr_e": "2015", "num_properties": 5, "num_properties_w-data": 5}]
128+
property_counts = response.json()["aggregated_data"]["property_counts"]
129+
expected = [{"yr_e": "2015", "num_properties": 5, "num_properties_w-data": 5, "cycle": self.cycle.name}]
130+
self.assertEqual(property_counts, expected)
126131

127132
def test_report_aggregated_count(self):
128133
url = reverse("api:v3:organizations-report-aggregated", args=[self.org.pk])
@@ -133,15 +138,18 @@ def test_report_aggregated_count(self):
133138
"access_level_instance_id": self.org.root.id,
134139
}
135140
response = self.client.get(url, data)
136-
assert response.json()["aggregated_data"]["property_counts"] == [
137-
{"yr_e": "2016", "num_properties": 5, "num_properties_w-data": 5},
138-
{"yr_e": "2015", "num_properties": 5, "num_properties_w-data": 5},
141+
property_counts = response.json()["aggregated_data"]["property_counts"]
142+
expected = [
143+
{"yr_e": "2016", "num_properties": 5, "num_properties_w-data": 5, "cycle": self.cycle_2.name},
144+
{"yr_e": "2015", "num_properties": 5, "num_properties_w-data": 5, "cycle": self.cycle.name},
139145
]
146+
self.assertEqual(property_counts, expected)
140147

141148
data["cycle_ids"] = [self.cycle.id]
142149
response = self.client.get(url, data)
143-
144-
assert response.json()["aggregated_data"]["property_counts"] == [{"yr_e": "2015", "num_properties": 5, "num_properties_w-data": 5}]
150+
property_counts = response.json()["aggregated_data"]["property_counts"]
151+
expected = [{"yr_e": "2015", "num_properties": 5, "num_properties_w-data": 5, "cycle": self.cycle.name}]
152+
self.assertEqual(property_counts, expected)
145153

146154
def test_report_missing_arg(self):
147155
url = reverse("api:v3:organizations-report-aggregated", args=[self.org.pk])

seed/views/v3/organizations.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,7 @@ def get_raw_report_data(self, organization_id, cycles, all_property_views, field
976976
"cycle_id": cycle.pk,
977977
"chart_data": data,
978978
"property_counts": {
979+
"cycle": cycle.name,
979980
"yr_e": cycle.end.strftime("%Y"),
980981
"num_properties": count_total,
981982
"num_properties_w-data": count_with_data,

0 commit comments

Comments
 (0)