@@ -106,12 +106,12 @@ Given a bunch of text representing a tool, either return a tool row object, or r
106106
107107=cut
108108
109- sub find_tool ($self , $name , $method ) {
110- my $tools_rs = $self -> db-> resultset(' Tool' )-> search_rs({name => $name });
109+ sub find_tool ($self , $name , $method , $args = undef ) {
110+ my $tools_rs = $self -> db-> resultset(' Tool' )-> search_rs({' me. name' => $name }, $args );
111111 if ($tools_rs -> count == 1) {
112112 return (' success' , $tools_rs -> first);
113113 }
114- $tools_rs = $self -> db-> resultset(' Tool' )-> search_rs({ name => { ' -like' => " %${name} %" }});
114+ $tools_rs = $self -> db-> resultset(' Tool' )-> search_rs({ ' me. name' => { ' -like' => " %${name} %" }}, $args );
115115 if ($tools_rs -> count == 1) {
116116 return (' success' , $tools_rs -> first);
117117 }
@@ -388,7 +388,7 @@ sub induct_member ($self, $text, $message, $args = undef) {
388388 if (!$args && $text =~ m { ^/induct\s ([\w\s ]+)\s on\s ([\w\d\s ]+)$} ) {
389389 my ($name , $tool_name ) = ($1 , $2 );
390390
391- ($p_status , $person_or_keyb ) = (' success' , $self -> db-> resultset(' Person' )-> find({ name => $name } ));
391+ ($p_status , $person_or_keyb ) = (' success' , $self -> db-> resultset(' Person' )-> find_person( $name ));
392392 ($t_status , $tool_or_keyb ) = $self -> find_tool($tool_name , ' induct_member' );
393393 if ($p_status eq ' success' ) {
394394 $person = $person_or_keyb ;
@@ -460,14 +460,11 @@ sub inducted_on ($self, $text, $message) {
460460
461461 if ($text =~ m { ^/inducted_on\s ([\w\s\d ]+)$} ) {
462462 my $tool_name = $1 ;
463- my $tool = $self -> db-> resultset(' Tool' )-> find(
464- {
465- name => $tool_name ,
466- },
463+ my ($status , $tool ) = $self -> find_tool($tool_name , ' inducted_on' ,
467464 {
468465 prefetch => {' allowed_people' => ' person' },
469466 });
470- if (! $tool ) {
467+ if ($status ne ' success ' ) {
471468 return $message -> reply(" I can't find a tool named $tool_name " );
472469 }
473470 my $str = join (" \n " , map {
@@ -487,7 +484,7 @@ sub inducted_on ($self, $text, $message) {
487484 if (!$str ) {
488485 $str = ' Nobody !?' ;
489486 }
490- return $message -> reply(" Inducted on $tool_name :\n $str " );
487+ return $message -> reply(" Inducted on " . $tool -> name . " :\n $str " );
491488 }
492489}
493490
@@ -505,8 +502,7 @@ sub inductions ($self, $text, $message) {
505502 if (!$name ) {
506503 $name = $member -> name;
507504 }
508- my $person = $self -> db-> resultset(' Person' )-> find(
509- { name => $name },
505+ my $person = $self -> db-> resultset(' Person' )-> find_person($name ,
510506 { prefetch => {' allowed' => ' tool' }});
511507 if (!$person ) {
512508 return $message -> reply(" I can't find a person named $name " );
@@ -516,7 +512,7 @@ sub inductions ($self, $text, $message) {
516512 if (!$str ) {
517513 $str = ' Nothing !?' ;
518514 }
519- return $message -> reply(" Inductions for $ name :\n $str " );
515+ return $message -> reply(" Inductions for " . $person -> name . " :\n $str " );
520516 }
521517}
522518
@@ -549,7 +545,7 @@ sub make_inductor ($self, $text, $message, $args = undef) {
549545 my ($name , $tool_name ) = ($1 , $2 );
550546
551547 # Find the target person:
552- ($p_status , $person_or_keyb ) = (' success' , $self -> db-> resultset(' Person' )-> find({ name => $name } ));
548+ ($p_status , $person_or_keyb ) = (' success' , $self -> db-> resultset(' Person' )-> find_person( $name ));
553549 # Find the tool (or return a status which will display buttons)
554550 ($t_status , $tool_or_keyb ) = $self -> find_tool($tool_name , ' make_inductor' );
555551 if ($p_status eq ' success' ) {
0 commit comments