| 1 | package IronMan::Schema::Result::Post; | ||
| 2 | |||
| 3 | 4 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 4 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 4 | ▶ | use base qw/DBIx::Class::Core/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 4 | __PACKAGE__->load_components(qw/InflateColumn::DateTime/); | |
| 9 | 4 | __PACKAGE__->table('posts'); | |
| 10 | 4 | __PACKAGE__->add_columns( | |
| 11 | post_id => { | ||
| 12 | data_type => 'integer', | ||
| 13 | is_auto_increment => 1, | ||
| 14 | }, | ||
| 15 | # FK to Feed | ||
| 16 | feed_id => { | ||
| 17 | data_type => 'varchar', | ||
| 18 | size => 255, | ||
| 19 | }, | ||
| 20 | url => { | ||
| 21 | data_type => 'varchar', | ||
| 22 | size => 1024, | ||
| 23 | }, | ||
| 24 | title => { | ||
| 25 | data_type => 'varchar', | ||
| 26 | size => 1024, | ||
| 27 | }, | ||
| 28 | posted_on => { | ||
| 29 | data_type => 'datetime', | ||
| 30 | }, | ||
| 31 | ## arbitrary size! | ||
| 32 | ## HTMLTruncate plugin to plagger truns to 300 at the moment | ||
| 33 | summary => { | ||
| 34 | data_type => 'text', | ||
| 35 | is_nullable => 1, | ||
| 36 | }, | ||
| 37 | body => { | ||
| 38 | data_type => 'text', | ||
| 39 | }, | ||
| 40 | summary_filtered => { | ||
| 41 | data_type => 'text', | ||
| 42 | is_nullable => 1, | ||
| 43 | }, | ||
| 44 | body_filtered => { | ||
| 45 | data_type => 'text', | ||
| 46 | is_nullable => 1, | ||
| 47 | }, | ||
| 48 | author => { | ||
| 49 | data_type => 'varchar', | ||
| 50 | size => 1024, | ||
| 51 | }, | ||
| 52 | tags => { | ||
| 53 | data_type => 'varchar', | ||
| 54 | size => 1024, | ||
| 55 | }, | ||
| 56 | ); | ||
| 57 | |||
| 58 | 4 | __PACKAGE__->set_primary_key('post_id'); | |
| 59 | 4 | __PACKAGE__->add_unique_constraint('url' => ['url']); | |
| 60 | |||
| 61 | 4 | __PACKAGE__->belongs_to('feed', 'IronMan::Schema::Result::Feed', 'feed_id'); | |
| 62 | |||
| 63 | __PACKAGE__->inflate_column('tags', { | ||
| 64 | 0 | ▶ | 'inflate' => sub { return [split(/,/,$_[0])] }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 65 | 0 | ▶ | 'deflate' => sub { return join(',', @{$_[0]}) }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 66 | 4 | }); | |
| 67 | |||
| 68 | 0 | ▶ | sub next_post { |
|
Subroutine
next_post: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 69 | 0 | my $self = shift; | |
| 70 | |||
| 71 | 0 | my $dt_parser = $self->result_source->storage->datetime_parser; | |
| 72 | |||
| 73 | 0 | return $self->result_source->resultset->search({ | |
| 74 | 'posted_on' => { '<' => $dt_parser->format_datetime($self->posted_on) }, | ||
| 75 | },{ | ||
| 76 | 'order_by' => \'posted_on DESC', | ||
| 77 | 'rows' => 1, | ||
| 78 | })->first; | ||
| 79 | } | ||
| 80 | |||
| 81 | 0 | ▶ | sub prev_post { |
|
Subroutine
prev_post: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 82 | 0 | my $self = shift; | |
| 83 | |||
| 84 | 0 | my $dt_parser = $self->result_source->storage->datetime_parser; | |
| 85 | |||
| 86 | 0 | return $self->result_source->resultset->search({ | |
| 87 | 'posted_on' => { '>' => $dt_parser->format_datetime($self->posted_on) }, | ||
| 88 | },{ | ||
| 89 | 'order_by' => \'posted_on ASC', | ||
| 90 | 'rows' => 1, | ||
| 91 | })->first; | ||
| 92 | } | ||
| 93 | |||
| 94 | 4 | 1; | |