/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 49 - (hide annotations)
Thu Feb 8 21:57:20 2007 UTC (17 years, 4 months ago) by dpavlin
File size: 3794 byte(s)
added some default values, always set per_page (to enable $filter->run to work!)
1 dpavlin 5 use strict;
2     use warnings;
3    
4     =head1 NAME
5    
6     SVNBrowser::Action::Filter
7    
8     =cut
9    
10     package SVNBrowser::Action::Filter;
11     use base qw/SVNBrowser::Action Jifty::Action/;
12    
13     use Data::Dump qw/dump/;
14    
15     use Jifty::Param::Schema;
16     use Jifty::Action schema {
17     param author =>
18     label is 'Developer login',
19     render as 'combobox',
20     available are defer {
21     my $authors = SVNBrowser::Model::RevisionCollection->new;
22     $authors->column(
23     column => 'author',
24     function => 'distinct',
25     );
26     $authors->unlimit;
27 dpavlin 27 $authors->order_by({ column => 'author', order => 'ASC' });
28     warn "authors ", $authors->build_select_query;
29 dpavlin 5 [{
30     display_from => 'author',
31     value_from => 'author',
32     collection => $authors,
33     }];
34     };
35    
36 dpavlin 26 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 dpavlin 27 $branches->order_by({ column => 'path', order => 'ASC' });
47     warn "branches ", $branches->build_select_query;
48 dpavlin 26 [{
49     display_from => 'path',
50     value_from => 'path',
51     collection => $branches,
52     }];
53     };
54    
55 dpavlin 47 param rel_path =>
56 dpavlin 49 label is 'Path begins with';
57 dpavlin 47
58 dpavlin 10 param show_actions =>
59     label is 'Show file actions',
60 dpavlin 49 render as 'checkbox',
61     default is 1;
62 dpavlin 10
63 dpavlin 13 param page =>
64     label is 'Current page';
65    
66     param per_page =>
67     label is 'Commits on page',
68     render as 'Select',
69 dpavlin 49 available are qw( 10 20 30 50 100 ),
70     default is 10;
71 dpavlin 13
72 dpavlin 14 param from_date =>
73     label is 'From date',
74     render as 'Date';
75    
76     param to_date =>
77     label is 'To date',
78     render as 'Date';
79    
80 dpavlin 19 param search =>
81     label is 'Search in messages';
82 dpavlin 14
83 dpavlin 5 };
84    
85     sub sticky_on_success { 1; }
86    
87     =head2 take_action
88    
89     =cut
90    
91     sub take_action {
92     my $self = shift;
93    
94 dpavlin 32 my $revisions = SVNBrowser::Model::RevisionCollection->new();
95     $revisions->unlimit();
96    
97     if ( my $author = $self->argument_value('author') ) {
98     $revisions->limit( column => 'author', value => $author, entry_aggregator => 'AND' );
99     }
100    
101     if ( my $from_date = $self->argument_value('from_date') ) {
102 dpavlin 41 $revisions->limit( column => 'commit_date', operator => '>=', value => $from_date, entry_aggregator => 'AND', case_sensitive => 1 );
103 dpavlin 32 }
104    
105     if ( my $to_date = $self->argument_value('to_date') ) {
106 dpavlin 41 $revisions->limit( column => 'commit_date', operator => '<=', value => $to_date, entry_aggregator => 'AND', case_sensitive => 1 );
107 dpavlin 32 }
108    
109     if ( my $search = $self->argument_value('search') ) {
110     $revisions->limit( column => 'message', operator => 'LIKE', value => '%' . $search . '%' );
111     }
112    
113     if ( my $branch = $self->argument_value('branch') ) {
114     my $b = SVNBrowser::Model::Branch->new();
115     $b->load_by_cols( path => $branch );
116    
117     my $rev_branches = $revisions->join(
118     alias1 => 'main', column1 => 'revision',
119     table2 => 'revision_branches', column2 => 'revision'
120     );
121     $revisions->limit( alias => $rev_branches, column => 'branch', value => $b->id );
122     }
123    
124 dpavlin 47 if ( my $rel_path = $self->argument_value('rel_path') ) {
125     my $rev_actions = $revisions->join(
126     alias1 => 'main', column1 => 'revision',
127     table2 => 'actions', column2 => 'revision'
128     );
129     $revisions->limit( alias => $rev_actions, column => 'rel_path', value => $rel_path, operator => 'STARTSWITH' );
130     }
131    
132 dpavlin 32 $revisions->order_by({ column => 'commit_date', order => 'desc' });
133     $revisions->set_page_info(
134     current_page => $self->argument_value('page'),
135 dpavlin 49 per_page => $self->argument_value('per_page') || 10,
136 dpavlin 32 );
137    
138     warn "take_action SQL: ", $revisions->build_select_query;
139    
140     $revisions->goto_first_item;
141    
142 dpavlin 10 my $msg = '';
143 dpavlin 32 if (my $nr = $revisions->pager->total_entries) {
144     $msg .= "Found $nr revisions";
145     } else {
146     $msg .= "No revisions found";
147     }
148    
149     $self->result->message($msg);
150    
151     $self->result->content( revisions => $revisions );
152    
153 dpavlin 5 return 1;
154     }
155    
156    
157     1;
158    

  ViewVC Help
Powered by ViewVC 1.1.26