/[SVNBrowser]/trunk/lib/SVNBrowser/Action/Filter.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/SVNBrowser/Action/Filter.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 14 by dpavlin, Wed Dec 6 20:42:13 2006 UTC revision 75 by dpavlin, Thu Jan 31 22:41:30 2008 UTC
# Line 15  use Data::Dump qw/dump/; Line 15  use Data::Dump qw/dump/;
15  use Jifty::Param::Schema;  use Jifty::Param::Schema;
16  use Jifty::Action schema {  use Jifty::Action schema {
17          param author =>          param author =>
18                  label is 'Developer login',                  label is _('Developer login'),
19                  render as 'combobox',                  render as 'combobox',
20                  available are defer {                  available are defer {
21                          my $authors = SVNBrowser::Model::RevisionCollection->new;                          my $authors = SVNBrowser::Model::RevisionCollection->new;
# Line 24  use Jifty::Action schema { Line 24  use Jifty::Action schema {
24                                  function => 'distinct',                                  function => 'distinct',
25                          );                          );
26                          $authors->unlimit;                          $authors->unlimit;
27                            $authors->order_by({ column => 'author', order => 'ASC' });
28                            warn "authors ", $authors->build_select_query;
29                          [{                          [{
30                                  display_from => 'author',                                  display_from => 'author',
31                                  value_from => 'author',                                  value_from => 'author',
# Line 31  use Jifty::Action schema { Line 33  use Jifty::Action schema {
33                          }];                          }];
34                  };                  };
35    
36            param branch =>
37                    label is _('In branch'),
38                    render as 'combobox',
39                    available are defer {
40                            my $branches = SVNBrowser::Model::BranchCollection->new;
41                            $branches->column(
42                                    column => 'path',
43                                    function => 'distinct',
44                            );
45                            $branches->unlimit;
46                            $branches->order_by({ column => 'path', order => 'ASC' });
47                            warn "branches ", $branches->build_select_query;
48                            [{
49                                    display_from => 'path',
50                                    value_from => 'path',
51                                    collection => $branches,
52                            }];
53                    };
54    
55            param rel_path =>
56                    label is _('Path begins with');
57    
58            param path =>
59                    label is _('Path contains');
60    
61          param show_actions =>          param show_actions =>
62                  label is 'Show file actions',                  label is _('Show file actions'),
63                  render as 'checkbox';                  render as 'checkbox',
64                    default is 1;
65    
66          param page =>          param page =>
67                  label is 'Current page';                  label is _('Current page');
68    
69          param per_page =>          param per_page =>
70                  label is 'Commits on page',                  label is _('Commits on page'),
71                  render as 'Select',                  render as 'Select',
72                  available are qw( 10 20 30 50 100 );                  available are qw( 10 20 30 50 100 ),
73                    default is 10;
74    
75          param from_date =>          param from_date =>
76                  label is 'From date',                  label is _('From date'),
77                  render as 'Date';                  render as 'Date';
78    
79          param to_date =>          param to_date =>
80                  label is 'To date',                  label is _('To date'),
81                  render as 'Date';                  render as 'Date';
82    
83            param search =>
84                    label is _('Search in messages');
85    
86  };  };
87    
# Line 63  sub sticky_on_success { 1; } Line 94  sub sticky_on_success { 1; }
94  sub take_action {  sub take_action {
95      my $self = shift;      my $self = shift;
96            
97          my $author = $self->argument_value('author');          my $revisions = SVNBrowser::Model::RevisionCollection->new();
98            $revisions->unlimit();
99    
100            if ( my $author = $self->argument_value('author') ) {
101                    $revisions->limit( column => 'author', value => $author, entry_aggregator => 'AND' );
102            }
103    
104            if ( my $from_date = $self->argument_value('from_date') ) {
105                    $revisions->limit( column => 'commit_date', operator => '>=', value => $from_date, entry_aggregator => 'AND', case_sensitive => 1 );
106            }
107    
108            if ( my $to_date = $self->argument_value('to_date') ) {
109                    $revisions->limit( column => 'commit_date', operator => '<=', value => $to_date, entry_aggregator => 'AND', case_sensitive => 1 );
110            }
111    
112            if ( my $search = $self->argument_value('search') ) {
113                    $revisions->limit( column => 'message', operator => 'LIKE', value => '%' . $search . '%' );
114            }
115    
116            if ( my $branch = $self->argument_value('branch') ) {
117                    my $b = SVNBrowser::Model::Branch->new();
118                    $b->load_by_cols( path => $branch );
119    
120                    my $rev_branches = $revisions->join(
121                            alias1 => 'main', column1 => 'revision',
122                            table2 => 'revision_branches', column2 => 'revision'
123                    );
124                    $revisions->limit( alias => $rev_branches, column => 'branch', value => $b->id );
125            }
126    
127            my $rev_actions = $revisions->join(
128                    alias1 => 'main', column1 => 'revision',
129                    table2 => 'actions', column2 => 'revision'
130            );
131    
132            if ( my $rel_path = $self->argument_value('rel_path') ) {
133                    $revisions->limit( alias => $rev_actions, column => 'rel_path', value => $rel_path, operator => 'STARTSWITH' );
134            }
135    
136            if ( my $path = $self->argument_value('path') ) {
137                    $revisions->limit( alias => $rev_actions, column => 'rel_path', value => $path, operator => 'MATCHES' );
138            }
139    
140            $revisions->order_by({ column => 'commit_date', order => 'desc' });
141            $revisions->set_page_info(
142                    current_page => $self->argument_value('page'),
143                    per_page => $self->argument_value('per_page') || 10,
144            );
145    
146            warn "take_action SQL: ", $revisions->build_select_query;
147    
148            $revisions->goto_first_item;
149    
150          my $msg = '';          my $msg = '';
151          $msg .= "Showing only commits for $author" if ($author);          if (my $nr = $revisions->pager->total_entries) {
152          $msg .= ( $msg ? ' and file actions' : 'Showing file actions for each commit' ) if ( $self->argument_value('show_actions') );                          $msg .= "Found $nr revisions";
153      $self->result->message($msg) if ($msg);          } else {
154                                $msg .= "No revisions found";
155            }
156    
157        $self->result->message($msg);
158    
159            $self->result->content( revisions => $revisions );
160    
161      return 1;      return 1;
162  }  }
163    

Legend:
Removed from v.14  
changed lines
  Added in v.75

  ViewVC Help
Powered by ViewVC 1.1.26