/[SVNBrowser]/branches/filter-action/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

Contents of /branches/filter-action/lib/SVNBrowser/Action/Filter.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 29 - (show annotations)
Sun Dec 10 17:21:02 2006 UTC (17 years, 4 months ago) by dpavlin
File size: 3434 byte(s)
begin refactoring of action
1 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 $authors->order_by({ column => 'author', order => 'ASC' });
28 warn "authors ", $authors->build_select_query;
29 [{
30 display_from => 'author',
31 value_from => 'author',
32 collection => $authors,
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 show_actions =>
56 label is 'Show file actions',
57 render as 'checkbox';
58
59 param page =>
60 label is 'Current page';
61
62 param per_page =>
63 label is 'Commits on page',
64 render as 'Select',
65 available are qw( 10 20 30 50 100 );
66
67 param from_date =>
68 label is 'From date',
69 render as 'Date';
70
71 param to_date =>
72 label is 'To date',
73 render as 'Date';
74
75 param search =>
76 label is 'Search in messages';
77
78 };
79
80 sub sticky_on_success { 1; }
81
82 =head2 take_action
83
84 =cut
85
86 sub take_action {
87 my $self = shift;
88
89 my $revisions = SVNBrowser::Model::RevisionCollection->new();
90 $revisions->unlimit();
91
92 if ( my $author = $self->argument_value('author') ) {
93 $revisions->limit( column => 'author', value => $author, entry_aggregator => 'AND' );
94 }
95
96 if ( my $from_date = $self->argument_value('from_date') ) {
97 $revisions->limit( column => 'commit_date', operator => '>=', value => $from_date, entry_aggregator => 'AND' );
98 }
99
100 if ( my $to_date = $self->argument_value('to_date') ) {
101 $revisions->limit( column => 'commit_date', operator => '>=', value => $to_date, entry_aggregator => 'AND' );
102 }
103
104 if ( my $search = $self->argument_value('search') ) {
105 $revisions->limit( column => 'message', operator => 'LIKE', value => '%' . $search . '%' );
106 }
107
108 if ( my $branch = $self->argument_value('branch') ) {
109 my $b = SVNBrowser::Model::Branch->new();
110 $b->load_by_cols( path => $branch );
111
112 my $rev_branches = $revisions->join(
113 alias1 => 'main', column1 => 'revision',
114 table2 => 'revision_branches', column2 => 'revision'
115 );
116 $revisions->limit( alias => $rev_branches, column => 'branch', value => $b->id );
117 }
118
119 $revisions->order_by({ column => 'commit_date', order => 'desc' });
120 $revisions->set_page_info(
121 current_page => $self->argument_value('page'),
122 per_page => $self->argument_value('per_page'),
123 );
124
125 warn "take_action SQL: ", $revisions->build_select_query;
126
127 $revisions->goto_first_item;
128
129 my $msg = '';
130 if (my $nr = $revisions->pager->total_entries) {
131 $msg .= "Found $nr revisions";
132 } else {
133 $msg .= "No revisions found";
134 }
135
136 $self->result->message($msg);
137
138 $self->result->content( revisions => $revisions );
139
140 use Data::Dump qw/dump/;
141 warn "take_action revisions = ",dump($revisions);
142
143 return 1;
144 }
145
146
147 1;
148

  ViewVC Help
Powered by ViewVC 1.1.26