Skip to content

Commit

Permalink
Optimise - remove unnecessary field retrieval
Browse files Browse the repository at this point in the history
This commit removes the automatic inclusion of the created user and time
fields when retrieving records. Whilst most of the time this was not a
problem, on some systems with many edits it was making the queries much
slower. The fields will now only be included when specifically required.
  • Loading branch information
abeverley committed Aug 26, 2024
1 parent 8754ce4 commit a8abbc0
Show file tree
Hide file tree
Showing 12 changed files with 351 additions and 245 deletions.
11 changes: 6 additions & 5 deletions lib/GADS/API.pm
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ sub _update_record
{
my $col = $record->layout->column_by_name_short($field)
or error __x"Column not found: {name}", name => $field;
$record->fields->{$col->id}->set_value($request->{$field});
$record->get_field_value($col)->set_value($request->{$field});
}
$record->write; # borks on error
};
Expand Down Expand Up @@ -441,7 +441,7 @@ prefix '/:layout_name' => sub {
foreach my $col (@{$curval->subvals_input_required})
{
my @vals = grep { defined $_ } query_parameters->get_all($col->field);
my $datum = $record->fields->{$col->id};
my $datum = $record->get_field_value($col);
$datum->set_value(\@vals);
}
$record->write(
Expand Down Expand Up @@ -1190,7 +1190,8 @@ sub _get_records {
my @filters;
foreach my $group_col_id (@{$records->group_col_ids})
{
my $filter_value = $rec->fields->{$group_col_id}->filter_value || '';
my $group_col = $layout->column($group_col_id);
my $filter_value = $rec->get_field_value($group_col)->filter_value || '';
push @filters, "$group_col_id=".uri_escape_utf8($filter_value);
}
my $desc = $rec->id_count == 1 ? 'record' : 'records';
Expand All @@ -1204,7 +1205,7 @@ sub _get_records {
else {
$data->{_id} = $rec->current_id;
};
$data->{$_->id} = $rec->fields->{$_->id}->for_table
$data->{$_->id} = $rec->get_field_value($_)->for_table
foreach @{$records->columns_render};

push @{$return->{data}}, $data;
Expand All @@ -1224,7 +1225,7 @@ sub _get_records {
if (my $agg = $records->aggregate_results)
{
my $data;
$data->{$_->id} = $agg->fields->{$_->id}->for_table
$data->{$_->id} = $agg->get_field_value($_)->for_table
foreach @{$records->columns_render};
$return->{aggregate} = $data;
}
Expand Down
Loading

0 comments on commit a8abbc0

Please sign in to comment.