X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=Memories%2FTag.pm;h=3354489cc661d3a15c9738dddb0687a7fecd669a;hb=5e39f2504d914454f14ef27aa2c1a567c2148d14;hp=e1afdd2f544715c613c9e7a44742c04084055ed0;hpb=f3c82666d618b39536e46f123109699e552bd3e7;p=memories.git diff --git a/Memories/Tag.pm b/Memories/Tag.pm index e1afdd2..3354489 100644 --- a/Memories/Tag.pm +++ b/Memories/Tag.pm @@ -5,10 +5,9 @@ __PACKAGE__->columns(Essential => qw/id name/); Memories::Photo->set_sql(sorted_by_tag => q/ SELECT photo.id as id, title, uploader, uploaded, x, y -FROM photo, tag, tagging +FROM photo, tagging WHERE tagging.photo = photo.id - AND tagging.tag = tag.id - AND tag.id = ? + AND tagging.tag = ? ORDER BY photo.uploaded DESC / ); @@ -28,7 +27,7 @@ sub view :Exported { $sth->finish; $r->{template_args}{tags} = \@tags; } else { - if (!$r->objects) { + if (!@{$r->objects||[]}) { $tag = $tags[0]; } else { $tag = $r->objects->[0]; @@ -38,6 +37,7 @@ sub view :Exported { $r->{template_args}{photos} = [$pager->search_sorted_by_tag($tag->id)]; } + $r->last_search(); } sub multi_search { @@ -74,28 +74,14 @@ sub list_js :Exported { package Memories::Tagging; use base qw(Memories::DBI); -use Class::DBI::Pager; -__PACKAGE__->columns(TEMP => qw/count/); -__PACKAGE__->columns(Essential => qw/id tag photo/); -__PACKAGE__->set_sql(summary => qq/ -SELECT id, tag, count(*) AS count -FROM tagging -GROUP BY tag -ORDER BY count DESC -LIMIT 75 - /); -__PACKAGE__->set_sql(all => qq/ -SELECT id, tag, count(*) AS count -FROM tagging + + +__PACKAGE__->set_sql(user_summary => qq/ +SELECT tagging.id id, tag, count(*) AS count +FROM tagging, photo +WHERE tagging.photo = photo.id AND photo.uploader = ? GROUP BY tag ORDER BY count DESC - /); -Memories::Tagging->has_a("photo" => "Memories::Photo"); -Memories::Tagging->has_a("tag" => "Memories::Tag"); - -Memories::Photo->has_many(tags => ["Memories::Tagging" => "tag"]); -Memories::Photo->has_many(taggings => "Memories::Tagging"); -Memories::Tag->has_many(photos => ["Memories::Tagging" => "photo"] ); -Memories::Tag->has_many(taggings => "Memories::Tagging"); +/); 1;