Skip to content
This repository has been archived by the owner on Jul 24, 2021. It is now read-only.

Commit

Permalink
separate out the device_report query from the rest
Browse files Browse the repository at this point in the history
This is apparently causing slowdowns on staging.
Addresses rollbar #51.

(cherry picked from commit 92ec76e)
  • Loading branch information
karenetheridge authored and sungo committed Sep 5, 2018
1 parent 6c32e0c commit 011ca3c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/Conch/Controller/Device.pm
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,21 @@ sub get ($c) {
{},
{
prefetch => [
'latest_report',
{ device_nics => 'device_neighbor' },
],
},
);

my $maybe_location = Conch::Model::DeviceLocation->new->lookup($device->id);

# this bit of the query is SLOW, so we don't add it to the prefetch list.
my $latest_report = $device->latest_report;

# TODO: we can collapse this all down to a self-contained serializer once the
# DeviceLocation query has been converted to a prefetchable relationship.
my $detailed_device = +{
%{ $device->TO_JSON },
latest_report => $device->latest_report->report,
latest_report => ($latest_report ? $latest_report->report : undef),
nics => [ map {
my $device_nic = $_;
$device_nic->deactivated ? () :
Expand Down

0 comments on commit 011ca3c

Please sign in to comment.