Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce some DB queries #4548

Merged
merged 2 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
- Auto-spot a default favicon.ico.
- Add `send_state` column to reports. #4048
- Return random unprocessed row to daemon.
- Performance improvements:
- Reduce database queries on shortlist page.
- Provide ResultSet fallback translation in lookup.
- Changes:
- Switch to OpenStreetMap for reverse geocoding. #4444

Expand Down
4 changes: 2 additions & 2 deletions perllib/FixMyStreet/App/Controller/My.pm
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ sub planned : Local : Args(0) {
$c->detach('/page_error_403_access_denied', [])
unless $c->user->has_body_permission_to('planned_reports');

$c->stash->{problems_rs} = $c->user->active_planned_reports;
$c->stash->{problems_rs} = $c->user->active_planned_reports->search(undef, { '+columns' => [ { 'upr_id' => 'me.id' } ] });
$c->forward('planned_reorder');
$c->forward('/reports/stash_report_sort', [ 'shortlist' ]);
$c->forward('get_problems');
Expand Down Expand Up @@ -322,7 +322,7 @@ sub by_shortlisted {
1; # Want non-ordered to come last
} else {
# Default to order added to planned reports
$a->user_planned_reports->first->id <=> $b->user_planned_reports->first->id;
$a->get_column('upr_id') <=> $b->get_column('upr_id');
}
}

Expand Down
2 changes: 1 addition & 1 deletion perllib/FixMyStreet/DB/ResultSet/Body.pm
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ sub translated {
my $rs = shift;
my $schema = $rs->result_source->schema;
$rs->search(undef, {
'+columns' => { 'msgstr' => 'translations.msgstr' },
'+columns' => { 'msgstr' => \'COALESCE(translations.msgstr, me.name)' },
join => 'translations',
bind => [ 'name', $schema->lang, 'body' ],
});
Expand Down
2 changes: 1 addition & 1 deletion perllib/FixMyStreet/DB/ResultSet/Contact.pm
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ sub translated {
my $rs = shift;
my $schema = $rs->result_source->schema;
$rs->search(undef, {
'+columns' => { 'msgstr' => 'translations.msgstr' },
'+columns' => { 'msgstr' => \"COALESCE(translations.msgstr, me.category)" },
join => 'translations',
bind => [ 'category', $schema->lang, 'contact' ],
});
Expand Down
2 changes: 1 addition & 1 deletion templates/web/base/report/_item_small.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
[% END %]
[% END %]

[% IF page != '' %]
[% IF page != '' AND c.req.url.path != '/my/planned' %]
<div class='assigned-to'>
[% INCLUDE 'admin/_report-assignment.html' %]
</div>
Expand Down