From 0ac6758a593e0e8ebad7af6aba3c3512d4d8280f Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Wed, 7 Feb 2007 23:17:57 +0000 Subject: [PATCH] Add SQL and code for the counter (References #4), but no interface yet; adds SQL structure for ratings. (References #6) git-svn-id: http://svn.simon-cozens.org/memories/trunk@9 041978f6-d955-411f-a9d7-1d8545c9c3c7 --- Memories/Photo.pm | 10 +++++++--- memories.sql | 5 ++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Memories/Photo.pm b/Memories/Photo.pm index 960810d..4279dc9 100644 --- a/Memories/Photo.pm +++ b/Memories/Photo.pm @@ -5,7 +5,7 @@ use base qw(Memories::DBI Maypole::Model::CDBI::Plain); use Time::Piece; use Image::Seek; use constant PAGER_SYNTAX => "LimitXY"; -__PACKAGE__->columns(Essential => qw(id title uploader uploaded x y)); +__PACKAGE__->columns(Essential => qw(id title uploader uploaded x y rating rated hit_count)); __PACKAGE__->untaint_columns(printable => [qw/title/]); __PACKAGE__->columns(TEMP => qw/exif_object/); __PACKAGE__->set_sql(recent => q{ @@ -30,7 +30,10 @@ sub do_upload :Exported { my $photo = $self->create({ uploader => $r->user, uploaded => Time::Piece->new(), - title => $r->params->{title} + title => $r->params->{title}, + hit_count => 0, + rating => 0, + rated => 0, # Oh, the potential for divide by zero errors... }); # Dump content @@ -71,8 +74,9 @@ sub do_upload :Exported { sub view :Exported { my ($self, $r) = @_; + my $photo = $r->{objects}[0]; + $photo->hit_count($photo->hit_count()+1); if ($r->{session}{last_search}) { - my $photo = $r->{objects}[0]; # This is slightly inefficient my @search = split/,/, $r->{session}{last_search}; my $found = -1; diff --git a/memories.sql b/memories.sql index 9ebe256..cf49797 100644 --- a/memories.sql +++ b/memories.sql @@ -4,7 +4,10 @@ CREATE TABLE photo ( uploader integer, uploaded datetime, x integer, - y integer + y integer, + hit_count integer, + rating integer, + rated integer ); CREATE TABLE comment ( -- 2.39.2