Skip to content
This repository
Browse code

Try to optimize query by using unique constraint.

  • Loading branch information...
commit 90ebc6a00834ff7cf466dd61ea3c42deb496a2f4 1 parent afdba62
Jeffrey Ryan Thalhammer authored

Showing 1 changed file with 5 additions and 3 deletions. Show diff stats Hide diff stats

  1. +5 3 lib/Pinto/Schema/Result/Package.pm
8 lib/Pinto/Schema/Result/Package.pm
@@ -196,10 +196,12 @@ sub register {
196 196 sub registration {
197 197 my ($self, %args) = @_;
198 198
199   - my $where = {name => $args{stack}};
200   - my $stack = $self->result_source->schema->resultset('Stack')->find($where);
  199 + my $where1 = {name => $args{stack}};
  200 + my $stack = $self->result_source->schema->resultset('Stack')->find($where1);
201 201
202   - return $self->find_related('registrations', {stack => $stack});
  202 + my $attrs = {key => 'stack_package_name_unique'};
  203 + my $where2 = {stack => $stack, package_name => $self->name};
  204 + return $self->find_related('registrations', $where2, $attrs);
203 205 }
204 206
205 207 #------------------------------------------------------------------------------

0 comments on commit 90ebc6a

Please sign in to comment.
Something went wrong with that request. Please try again.