summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOthmar Gsenger <otti@wirdorange.org>2013-01-17 21:26:21 (GMT)
committerOthmar Gsenger <otti@wirdorange.org>2013-01-17 21:26:21 (GMT)
commit8c6ab52c7e324c7ddc4997846ea5900ae2215e41 (patch)
treeb3fefd13baa4a7f9ac87f88e462970361d7af3de
parent761222eb1133d5ba6d48785719e8ff3b343499aa (diff)
added download counter
-rw-r--r--local/db.pm2
-rw-r--r--nzbget/list.pm10
2 files changed, 10 insertions, 2 deletions
diff --git a/local/db.pm b/local/db.pm
index dbb5d7d..517eadb 100644
--- a/local/db.pm
+++ b/local/db.pm
@@ -31,6 +31,8 @@ local::db::seen->table('seen');
local::db::seen->columns(All => qw/seen_id download user/);
local::db::seen->has_a(download => 'local::db::download');
local::db::seen->has_a(user => 'local::db::owner');
+local::db::seen->set_sql(count_download => qq{ SELECT COUNT(user) as dlcount ,download FROM seen GROUP BY download });
+
package local::db::ip;
use base 'local::db::dbi';
diff --git a/nzbget/list.pm b/nzbget/list.pm
index e4f0565..91e5718 100644
--- a/nzbget/list.pm
+++ b/nzbget/list.pm
@@ -24,7 +24,13 @@ sub handler
print table({class=>'nohigh'},Tr(td({align=>'right'},['benutzter Speicherplatz &nbsp; '. $user->obj->quota_used().' / '.$user->obj->quoata().' MB']))) if ($only_me);
print CGI::start_table();
- print Tr(th([qw/Neu Kategorie Name Größe Löschen /]));
+ print Tr(th([qw/Neu # Kategorie Name Größe Löschen /]));
+ # SELECT COUNT(user),download FROM seen GROUP BY download
+ my %dl_counts;
+ for my $dl_count ( local::db::seen->search_count_download())
+ {
+ $dl_counts{$dl_count->{download}}=$dl_count->{dlcount};
+ }
my @downloads = local::db::download->search(
$only_me ? (owner=>$user->get_id()) : () ,
param('category') ? (category => param('category')) : (),
@@ -34,7 +40,7 @@ sub handler
my $dl_remove;
$dl_remove = a({href=>'remove?id='.$dl->download_id},$dl->owner->name) if $user->is_admin();
$dl_remove = a({href=>'remove?id='.$dl->download_id},"löschen") if $dl->owner->owner_id == $user->get_id;
- print Tr(td([ (local::db::seen->search(user=>$user->get_id(),download=>$dl->download_id))?'':'x',
+ print Tr(td([ (local::db::seen->search(user=>$user->get_id(),download=>$dl->download_id))?'':'x',$dl_counts{$dl->download_id},
a({href=>"$module?category=".$dl->category->category_id},$dl->category->name),a({title=>$dl->description,href=>'read?id='.$dl->download_id},$dl->name),$dl->size.'MB',$dl_remove
]));