[Catalyst-dev] Advent 2007

J. Shirley jshirley at gmail.com
Fri Nov 9 16:35:52 GMT 2007


On Nov 9, 2007 2:08 AM, Zbigniew Lukasiak <zzbbyy at gmail.com> wrote:

> I think I can write something on 'advanced search' - that is how to
> build a search query from form parameters.  Including columns from
> related tables, tags, full text search and search by proximity.  Full
> text and proximity based on PostgreSQL features, proximity only for
> planar spaces - I've found a patch for PostgreSQL implementing a
> spherical geometry, but it looked a bit scary - if someone has any
> experience with that please comment.
>
> The base of that would be a ResultSet base class with that simple sub
> (this is directly from our working environment):
>
> sub advanced_search {
>    my ( $self, $params ) =3D @_;
>    my $rs =3D $self; #->search( );
>    if( $params->{tags} and my $subref =3D $self->can( 'search_for_' .
> 'tags' ) ){
>        # tags need to be joined first
>        # this is a hack around DBIC bug (fixed in the svn trunk)
>            $rs =3D &$subref( $self, $rs, $params );
>    }
>    for my $column ( keys %$params ){
>        next if $column eq 'tags';
>        if( my $subref =3D $self->can( 'search_for_' . $column ) ){
>            $rs =3D &$subref( $self, $rs, $params );
>            next;
>        }
>        if ( $self->result_source->has_column( $column ) ){
>            $rs =3D $rs->search( { $column =3D> $params->{$column} } );
>            next;
>        }
>        if ( $column =3D~ /(.*)\.(.*)/ ){
>            my $relation =3D $1;
>            $rs =3D $rs->search(
>                { $column =3D> $params->{$column} },
>                { join =3D> [ $relation ] }
>            );
>        }
>    }
>    return $rs;
> }
>
> It assumes that $params contain validated and filtered parameters.
>
> I also attach the full class.
>
> What do you think?  Would that be an interesting subject?  Any
> suggestions for the code?
>
> --
> Zbigniew Lukasiak
> http://perlalchemy.blogspot.com/
>
>
>
That does sound like a very interesting subject, and if you can create a
little example app that folks can download and tinker with all the better.
I chuck my examples up at
http://dev.catalystframework.org/repos/Catalyst/trunk/examples/ - most of
the time it is ignored but it is very good to point people to.

Let me know if you want help setting up a sample app around it and I'll do
what I can.

Which day works best for you?  I'll schedule you in.

-J

-- =

J. Shirley :: jshirley at gmail.com :: Killing two stones with one bird...
http://www.toeat.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst-dev/attachments/20071109/7=
f9ca12e/attachment-0001.htm


More information about the Catalyst-dev mailing list