sub slug { shift->{slug} }
sub name { shift->{name} }
- sub video_count { shift->{video_count} }
+ sub video_count {
+ exists $_[0]->{video_count}
+ ? $_[0]->{video_count}
+ : $_[0]->{videos}->count
+ }
sub videos { shift->{videos} }
package App::IdiotBox::Video;
1, '2009-12-25 09:00:00', 'lpw2009'
);
INSERT INTO announcements (id, made_at, bucket_slug) VALUES (
- 2, '2010-01-01 14:00:00', 'lpw2009',
+ 2, '2010-01-01 14:00:00', 'lpw2009'
);
INSERT INTO announcements (id, made_at, bucket_slug) VALUES (
3, '2010-01-21 01:00:00', 'opw2010'
INSERT INTO videos (
slug, bucket_slug, name, author,announcement_id
) VALUES (
- 'keynote', 'opw2010', 'The Most Disgusting Word You''ll Hear'
- 'Mark Keating (mdk)', 4
+ 'keynote', 'opw2010', 'The Most Disgusting Word You''ll Hear',
+ 'Mark Keating (mdk)', 3
);