From: Matt S Trout Date: Wed, 20 Jan 2010 11:04:45 +0000 (+0000) Subject: sort of works with store X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FApp-IdiotBox.git;a=commitdiff_plain;h=d9702c6d2c59be57383275e22cbc7c8b11c54ba6 sort of works with store --- diff --git a/lib/App/IdiotBox.pm b/lib/App/IdiotBox.pm index 12393e8..c59240c 100644 --- a/lib/App/IdiotBox.pm +++ b/lib/App/IdiotBox.pm @@ -16,7 +16,11 @@ use HTML::Zoom; 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; diff --git a/share/sql/example-data-1.0.sql b/share/sql/example-data-1.0.sql index 909d18d..519a62c 100644 --- a/share/sql/example-data-1.0.sql +++ b/share/sql/example-data-1.0.sql @@ -9,7 +9,7 @@ INSERT INTO announcements (id, made_at, bucket_slug) VALUES ( 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' @@ -34,6 +34,6 @@ INSERT INTO videos ( 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 );