[vhffs-dev] [1218] added stats about tags (Beno?\195?\174t Audouard patch) |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1218
Author: gradator
Date: 2008-06-05 23:51:10 +0200 (Thu, 05 Jun 2008)
Log Message:
-----------
added stats about tags (Beno?\195?\174t Audouard patch)
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Stats.pm
trunk/vhffs-panel/admin/stats.pl
trunk/vhffs-panel/templates/admin/misc/stats.tmpl
Modified: trunk/vhffs-api/src/Vhffs/Stats.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Stats.pm 2008-06-04 21:24:00 UTC (rev 1217)
+++ trunk/vhffs-api/src/Vhffs/Stats.pm 2008-06-05 21:51:10 UTC (rev 1218)
@@ -447,7 +447,75 @@
return $self->{groups}{total};
}
+sub get_tags_categories_total
+{
+ my $self = shift;
+ unless(defined $self->{tags_categories}{total}) {
+ my $sql = 'SELECT COUNT(*) FROM vhffs_tag_category';
+ ($self->{tags_categories}{total}) = @{$self->{db}->selectrow_arrayref( $sql )};
+ }
+ return $self->{tags_categories}{total};
+}
+sub get_tags_total
+{
+ my $self = shift;
+ unless(defined $self->{tags}{total}) {
+ my $sql = 'SELECT COUNT(*) FROM vhffs_tag';
+ ($self->{tags}{total}) = @{$self->{db}->selectrow_arrayref( $sql )};
+ }
+ return $self->{tags}{total};
+}
+
+sub get_tags_used_total
+{
+ my $self = shift;
+ unless(defined $self->{tags_used}{total}) {
+ my $sql = 'SELECT COUNT(distinct tag_id) FROM vhffs_object_tag';
+ ($self->{tags_used}{total}) = @{$self->{db}->selectrow_arrayref( $sql )};
+ }
+ return $self->{tags_used}{total};
+}
+
+sub get_tags_groups_total
+{
+ my $self = shift;
+ unless(defined $self->{tags_groups}{total}) {
+ my $sql = 'SELECT COUNT(distinct object_id) FROM vhffs_object_tag';
+ ($self->{tags_groups}{total}) = @{$self->{db}->selectrow_arrayref( $sql )};
+ }
+ return $self->{tags_groups}{total};
+}
+
+sub get_most_popular_tags
+{
+ my $self = shift;
+ # well, I did not succeed to use $self->{tags}{most_popular}
+ my $tags = [];
+ my $sql = 'SELECT vhffs_tag_category.label as category, vhffs_tag.label as tag_label, COUNT(object_id) as nb_groups
+ FROM vhffs_object_tag, vhffs_tag_category, vhffs_tag
+ WHERE vhffs_tag.category_id=vhffs_tag_category.tag_category_id
+ AND vhffs_object_tag.tag_id=vhffs_tag.tag_id
+ GROUP BY category,tag_label ORDER BY nb_groups DESC LIMIT 10';
+ my $sth = $self->{db}->prepare($sql);
+ $sth->execute() or return undef;
+ while( (my $t = $sth->fetchrow_hashref() ) ) {
+ push @$tags, $t;
+ }
+ return $tags;
+}
+
+sub get_tags_groups_max
+{
+ my $self = shift;
+
+ unless(defined $self->{tags_groups}{max}) {
+ my $sql = 'SELECT MAX(count_tag_id) FROM (select COUNT(tag_id) as count_tag_id, object_id FROM vhffs_object_tag GROUP BY object_id) AS count_tags_groups';
+ ($self->{tags_groups}{max}) = @{$self->{db}->selectrow_arrayref( $sql )};
+ }
+ return $self->{tags_groups}{max};
+}
+
1;
Modified: trunk/vhffs-panel/admin/stats.pl
===================================================================
--- trunk/vhffs-panel/admin/stats.pl 2008-06-04 21:24:00 UTC (rev 1217)
+++ trunk/vhffs-panel/admin/stats.pl 2008-06-05 21:51:10 UTC (rev 1218)
@@ -49,6 +49,7 @@
use Vhffs::Stats;
use Vhffs::Constants;
+
my $panel = new Vhffs::Panel::Main();
exit 0 unless $panel;
my $session = $panel->get_session;
@@ -170,6 +171,39 @@
$template->param( VALUE_TOTAL_LISTS_ACTIVATED => $stats->get_lists_activated );
$template->param( TEXT_TOTAL_SUBS => gettext("Total subscribtion for lists") );
$template->param( VALUE_TOTAL_SUBS => $stats->get_lists_totalsubs );
+
+ #tags part
+ $template->param( TEXT_TAGS => gettext("Tags stats") );
+ $template->param( TEXT_TOTAL_TAGS_CATEGORIES => gettext("Total categories") );
+ $template->param( VALUE_TOTAL_TAGS_CATEGORIES => $stats->get_tags_categories_total );
+ $template->param( TEXT_TOTAL_TAGS_USED_EXISTING => gettext("Total tags used") );
+ $template->param( VALUE_TOTAL_TAGS_USED => $stats->get_tags_used_total );
+ #$template->param( TEXT_TOTAL_TAGS_EXISTING => gettext("Total tags existing") );
+ $template->param( VALUE_TOTAL_TAGS_EXISTING => $stats->get_tags_total );
+ $template->param( TEXT_TOTAL_TAGS_GROUPS => gettext("Total tagged groups" ) );
+ $template->param( VALUE_TOTAL_TAGS_GROUPS => $stats->get_tags_groups_total );
+ $template->param( TEXT_MAX_TAGS_GROUPS => gettext("Max tags for a group" ) );
+ $template->param( VALUE_MAX_TAGS_GROUPS => $stats->get_tags_groups_max );
+ $template->param( TEXT_10MOST_USED_TAGS => gettext("Popular tags" ) );
+ #my $tags = Vhffs::Tag::get_10_tagsgroups($panel->{vhffs});
+ #my $sql = q{SELECT vhffs_tag_category.label as category, vhffs_tag.label as tag_label, COUNT(object_id) as nb_groups
+ #FROM vhffs_object_tag, vhffs_tag_category, vhffs_tag
+ #WHERE vhffs_tag.category_id=vhffs_tag_category.tag_category_id
+ #AND vhffs_object_tag.tag_id=vhffs_tag.tag_id
+ #GROUP BY category,tag_label ORDER BY nb_groups DESC LIMIT 10};
+
+ #my $tags = [];
+ #my $main = $panel->{vhffs};
+
+ #my $dbh = $main->get_db_object();
+ #my $sth = $dbh->prepare($sql);
+ #$sth->execute() or return undef;
+ #while( (my $t = $sth->fetchrow_hashref() ) ) {
+ #push @$tags, $t;
+ #}
+
+ $template->param( 'TAGS' => $stats->get_most_popular_tags );
+
}
$panel->build( $template );
Modified: trunk/vhffs-panel/templates/admin/misc/stats.tmpl
===================================================================
--- trunk/vhffs-panel/templates/admin/misc/stats.tmpl 2008-06-04 21:24:00 UTC (rev 1217)
+++ trunk/vhffs-panel/templates/admin/misc/stats.tmpl 2008-06-05 21:51:10 UTC (rev 1218)
@@ -98,3 +98,15 @@
<li><TMPL_VAR ESCAPE=1 NAME="TEXT_TOTAL_SUBS">: <TMPL_VAR ESCAPE=1 NAME="VALUE_TOTAL_SUBS"></li>
</ul>
+<h2>
+ <TMPL_VAR ESCAPE=1 NAME="TEXT_TAGS">:
+</h2>
+<ul>
+ <li><TMPL_VAR ESCAPE=1 NAME="TEXT_TOTAL_TAGS_CATEGORIES">: <TMPL_VAR ESCAPE=1 NAME="VALUE_TOTAL_TAGS_CATEGORIES"></li>
+ <li><TMPL_VAR ESCAPE=1 NAME="TEXT_TOTAL_TAGS_USED_EXISTING">: <TMPL_VAR ESCAPE=1 NAME="VALUE_TOTAL_TAGS_USED"> / <TMPL_VAR ESCAPE=1 NAME="VALUE_TOTAL_TAGS_EXISTING"></li>
+ <li><TMPL_VAR ESCAPE=1 NAME="TEXT_TOTAL_TAGS_GROUPS">: <TMPL_VAR ESCAPE=1 NAME="VALUE_TOTAL_TAGS_GROUPS"> / <TMPL_VAR ESCAPE=1 NAME="VALUE_TOTAL_GROUPS_ACTIVATED"></li>
+ <li><TMPL_VAR ESCAPE=1 NAME="TEXT_MAX_TAGS_GROUPS">: <TMPL_VAR ESCAPE=1 NAME="VALUE_MAX_TAGS_GROUPS"> </li>
+ <TMPL_IF NAME="TAGS"><li><TMPL_VAR ESCAPE=1 NAME="TEXT_10MOST_USED_TAGS">: <TMPL_LOOP NAME="TAGS"><TMPL_VAR NAME="category">:<TMPL_VAR NAME="tag_label" ESCAPE="1"> (<TMPL_VAR NAME="nb_groups">) </TMPL_LOOP>
+ </li></TMPL_IF>
+</ul>
+