/[Frey]/trunk/lib/Frey/Collection.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/Frey/Collection.pm

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

revision 108 by dpavlin, Sun Jul 13 12:22:14 2008 UTC revision 109 by dpavlin, Sun Jul 13 13:09:56 2008 UTC
# Line 2  package Frey::Collection; Line 2  package Frey::Collection;
2  use Moose::Role;  use Moose::Role;
3    
4  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
5    use Carp;
6    
7  sub collection {  sub collection {
8          my ( $class, $limit, $offset ) = @_;          my ( $class, $args ) = @_;
9    
10            croak "expect HASH not ",dump( $args ) unless ref($args) eq 'HASH';
11    
12            warn "## collection args = ",dump( $args );
13    
14          my $schema = $class->SchemaClass()->Schema();          my $schema = $class->SchemaClass()->Schema();
15          my $select = $class->SchemaClass()->SQLFactoryClass()->new_select();          my $select = $class->SchemaClass()->SQLFactoryClass()->new_select();
16    
# Line 12  sub collection { Line 18  sub collection {
18    
19          warn "## table $table";          warn "## table $table";
20    
         $limit ||= 20;  
         $offset ||= 0;  
   
21          my $users_t = $schema->table( $table );          my $users_t = $schema->table( $table );
22    
23          $select->select( $users_t )          $select->select( $users_t )
24                  ->from( $users_t )                  ->from( $users_t )
25  #               ->where( $message_t->column('message_date'), '>=',  #               ->where( $message_t->column('message_date'), '>=',
26  #                       DateTime->today()->subtract( days => 7 )->strftime( '%Y-%m-%d' ) )  #                       DateTime->today()->subtract( days => 7 )->strftime( '%Y-%m-%d' ) )
27                  ->limit( $limit, $offset )                  ->limit( $args->{limit} || 20, $args->{offset} || 0 )
28                  ;                  ;
29    
30          my $dbh = $class->_dbh($select);          my $dbh = $class->_dbh($select);

Legend:
Removed from v.108  
changed lines
  Added in v.109

  ViewVC Help
Powered by ViewVC 1.1.26