Hopefully fix speed issue on external data

This commit is contained in:
Thomas Bloor 2019-09-09 15:37:26 +01:00
parent 3b8b5b97f4
commit 962cf972da
No known key found for this signature in database
GPG key ID: 4657C7EBE42CC5CC
19 changed files with 182 additions and 156 deletions

View file

@ -98,4 +98,24 @@ sub post_transactions {
return $c->redirect_to('/admin/import_from');
}
sub org_search {
my $c = shift;
my $term = $c->param('term');
my $rs = $c->schema->resultset('Organisation')->search(
{ name => { like => $term . '%' } },
{
join => 'entity',
columns => [ qw/ me.name entity.id / ]
},
);
my @results = ( map { {
label => $_->name,
value => $_->entity->id,
} } $rs->all);
$c->render( json => \@results );
}
1;