[Rt-commit] rt branch, 4.4/rt-search-attributes, repushed

Dustin Graves dustin at bestpractical.com
Thu Oct 22 12:48:23 EDT 2015


The branch 4.4/rt-search-attributes was deleted and repushed:
       was 992230707bbb8f7e6a9ac74885ad5aac396e091a
       now 589ee4832e1bde5421344694c8d057b54614e44f

1:  9922307 ! 1:  589ee48 add script to search attributes
    @@ -108,17 +108,41 @@
     +
     +use Data::Dumper;
     +
    -+while ( $_ = $attrs->Next ) {
    ++# compile search code into sub since eval is slow
    ++my $predicate;
    ++$predicate = eval "
    ++    sub {
    ++        my \$attr = shift;
    ++        my (      \$Id,       \$ObjectType,       \$ObjectId,       \$Name,       \$Description,       \$Content) =
    ++           (\$attr->Id, \$attr->ObjectType, \$attr->ObjectId, \$attr->Name, \$attr->Description, \$attr->Content);
    ++
    ++        # allow lowercase to be kind
    ++        my (\$id, \$objecttype, \$objectid, \$name, \$description, \$content) =
    ++           (\$Id, \$ObjectType, \$ObjectId, \$Name, \$Description, \$Content);
    ++
    ++        # shorthand for content
    ++        \$_ = \$attr->Content;
    ++
    ++        # return executed search code
    ++        $search;
    ++    }" if defined $search;
    ++
    ++if (defined $search and not defined $predicate) {
    ++    print "Error evaluating expression '$search'\n";
    ++    exit;
    ++}
    ++
    ++while ( my $attr = $attrs->Next ) {
     +    # search for desired field
    -+    if (not $search or eval $search) {
    ++    if (not defined $predicate or $predicate->($attr)) {
     +        # print attribute's information
     +        foreach my $field ( @fields ) {
    -+            print "$field: " . $_->$field . "\n";
    ++            print "$field: " . $attr->$field . "\n";
     +        }
     +        # print content
    -+        print Data::Dumper->Dump([$_->Content], ['Content']) if ($args{content});
    ++        print Data::Dumper->Dump([$attr->Content], ['Content']) if ($args{content});
     +        print "\n";
    -+    } 
    ++    }
     +}
     +
     +
    @@ -126,7 +150,7 @@
     +
     +=head1 NAME
     +
    -+rt-search-attributes - search attributes
    ++rt-search-attributes - search RT::Attribute objects
     +
     +=head1 SYNOPSIS
     +
    @@ -138,6 +162,11 @@
     +qualifying code QUALIFYING_CODE and prints out the details of matching
     +attributes.
     +
    ++QUALIFYING_CODE can use a number of variables to call on RT::Attribute's
    ++properties:
    ++   $Id, $ObjectType, $ObjectId, $Name, $Description, $Content
    ++   $_ is available as shorthand for $Content
    ++
     +-c, --content
     +    Print attribute content
     +
    @@ -146,5 +175,6 @@
     +
     +e.g.
     +
    -+rt-search-attributes SavedSearch '$_->id > 10'
    ++rt-search-attributes SavedSearch '$id > 10'
     +rt-search-attributes HomepageSettings
    ++rt-search-attributes Search '$_->{Query} =~ /Status/'



More information about the rt-commit mailing list