Skip to content

Commit

Permalink
Fix regression of performance
Browse files Browse the repository at this point in the history
  • Loading branch information
abeverley committed Oct 20, 2024
1 parent 2a1560b commit 9fff419
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lib/GADS/Record.pm
Original file line number Diff line number Diff line change
Expand Up @@ -459,10 +459,12 @@ has created_user => (

my $column = $self->layout->column_by_name_short('_created_user');

my $value = $self->set_record_created_user || $self->record->{record_created_user};

# Has it been retrieved as part of sql query?
if ($self->record && exists $self->record->{record_created_user})
if ($value)
{
return $self->_person($self->record->{record_created_user}, $column);
return $self->_person($value, $column);
}

my $user = $self->first_record_rs->createdby;
Expand Down Expand Up @@ -518,7 +520,7 @@ has edited_user => (
# Has it been retrieved as part of sql query?
if ($self->record && exists $self->record->{createdby})
{
return $self->_person($self->record->{createdby}, $column);
return $self->_person($self->record->{$column->field}, $column);
}

my $user = $self->record_rs->createdby;
Expand Down
13 changes: 12 additions & 1 deletion lib/GADS/Records.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ sub _build_standard_results
set_record_created => $rec->{record_created_date},
);
$record->set_record_created_user($rec->{record_created_user})
if exists $rec->{record_creted_user};
if exists $rec->{record_created_user};
push @all, $record;
push @created_ids, $rec->{record_created_user};
push @record_ids, $rec->{id};
Expand All @@ -1288,6 +1288,17 @@ sub _build_standard_results
already_seen => $self->already_seen,
);

# Fetch and add created users (unable to retrieve during initial query)
my $created_column = $self->layout->column_by_name_short('_created_user');
my $created_users = $created_column->fetch_multivalues(\@created_ids);
foreach my $rec (@all)
{
my $original = $rec->set_record_created_user
or next;
my $user = $created_users->{$original};
$rec->set_record_created_user($user);
}

\@all;
}

Expand Down

0 comments on commit 9fff419

Please sign in to comment.