Skip to content

Commit

Permalink
Tidy, add spec
Browse files Browse the repository at this point in the history
  • Loading branch information
ldodds committed Jan 24, 2025
1 parent 49e9637 commit c4e5705
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin/prob_data_reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def find_prob_data
.joins('LEFT JOIN school_groups on schools.school_group_id = school_groups.id')
.where(status: 'PROB')
.group('school_groups.name', 'schools.name', 'schools.slug', 'meters.meter_type', 'meters.name', :mpan_mprn, 'meters.id')
.order('count(mpan_mprn) DESC')
.order('count(mpan_mprn) DESC, school_groups.name, schools.name')
.count
.map { |row| row.to_a.flatten }
end
Expand Down
24 changes: 19 additions & 5 deletions app/views/admin/prob_data_reports/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,26 @@
<%= header_nav_link 'Admin', admin_url %>
<% end %>

<table class="table table-sorted">
<p>
Lists all of the meters in the system that have one or more "PROB" data readings.
These are readings where we have missing data but the analytics has been unable to
find a good substitute.
</p>

<p>
The report can be used to identify meters with very poor data quality, as well as
examples of where we might improve our substitutions rules.
</p>

<table id="report" class="table table-sorted">
<thead>
<tr>
<th>School group</th>
<th>School</th>
<th>Meter name/mpan/mprn</th>
<th>Meter name</th>
<th>MPXN</th>
<th>Meter type</th>
<th>Count of PROB records</th>
<th>Count</th>
</tr>
</thead>
<tbody>
Expand All @@ -20,8 +32,10 @@
<%= link_to row[1], school_meters_path(school_id: row[2]) %>
</td>
<td>
<%= link_to [row[4], row[5]].reject(&:blank?).join(': '),
admin_reports_amr_validated_reading_url(meter_id: row[6]) %>
<%= row[4] %>
</td>
<td>
<%= link_to row[5], admin_reports_amr_validated_reading_url(meter_id: row[6]) %>
</td>
<td><%= row[3] %></td>
<td>
Expand Down

0 comments on commit c4e5705

Please sign in to comment.