[vhffs-dev] [2239] add stats for tag cloud (by category / by tag) |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 2239
Author: baud123
Date: 2013-11-19 01:09:45 +0100 (Tue, 19 Nov 2013)
Log Message:
-----------
add stats for tag cloud (by category / by tag)
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Panel/Stats.pm
trunk/vhffs-api/src/Vhffs/Stats.pm
trunk/vhffs-panel/templates/admin/misc/stats.tt
Modified: trunk/vhffs-api/src/Vhffs/Panel/Stats.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Stats.pm 2013-11-12 17:10:14 UTC (rev 2238)
+++ trunk/vhffs-api/src/Vhffs/Panel/Stats.pm 2013-11-19 00:09:45 UTC (rev 2239)
@@ -107,7 +107,9 @@
total_tags_count => $stats->get_tags_total,
tagged_groups_count => $stats->get_tags_groups_total,
max_tags_count => $stats->get_tags_groups_max,
- top10_tags => $stats->get_most_popular_tags
+ top10_tags => $stats->get_most_popular_tags,
+ all_tags => $stats->get_all_tags,
+ all_sorted_tags => $stats->get_all_sorted_tags
};
$panel->render('admin/misc/stats.tt', $vars);
Modified: trunk/vhffs-api/src/Vhffs/Stats.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Stats.pm 2013-11-12 17:10:14 UTC (rev 2238)
+++ trunk/vhffs-api/src/Vhffs/Stats.pm 2013-11-19 00:09:45 UTC (rev 2239)
@@ -781,6 +781,58 @@
=pod
+=head2 get_all_tags
+
+ my $tags = $stats->get_all_tags();
+
+Returns all the tags by category.
+
+=cut
+sub get_all_tags {
+ my $self = shift;
+ # well, I did not succeed to use $self->{stats}->{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 category, tag_label';
+ my $sth = $self->{vhffs}->get_db->prepare($sql);
+ $sth->execute() or return undef;
+ while( (my $t = $sth->fetchrow_hashref() ) ) {
+ push @$tags, $t;
+ }
+ return $tags;
+}
+
+=pod
+
+=head2 get_all_sorted_tags
+
+ my $tags = $stats->get_all_sorted_tags();
+
+Returns all the tags by alphabetical order, without category.
+
+=cut
+sub get_all_sorted_tags {
+ my $self = shift;
+ # well, I did not succeed to use $self->{stats}->{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 tag_label';
+ my $sth = $self->{vhffs}->get_db->prepare($sql);
+ $sth->execute() or return undef;
+ while( (my $t = $sth->fetchrow_hashref() ) ) {
+ push @$tags, $t;
+ }
+ return $tags;
+}
+
+=pod
+
=head2 get_most_popular_tags
my $tags = $stats->get_most_popular_tags();
Modified: trunk/vhffs-panel/templates/admin/misc/stats.tt
===================================================================
--- trunk/vhffs-panel/templates/admin/misc/stats.tt 2013-11-12 17:10:14 UTC (rev 2238)
+++ trunk/vhffs-panel/templates/admin/misc/stats.tt 2013-11-19 00:09:45 UTC (rev 2239)
@@ -97,4 +97,13 @@
<li>[% '10 most used tags:' | i18n | html %]: [% FOREACH t IN top10_tags %][% t.category %]::[% t.tag_label %] ([% t.nb_groups %])[% ', ' UNLESS loop.last() %][% END %]</li>
[% END %]
</ul>
+<h2>[% 'Tags cloud / category' | i18n | html %]</h2>
+[% IF all_tags.size() > 0 %]
+[% FOREACH t IN all_tags %][% t.category %]::[% t.tag_label %] ([% t.nb_groups %])[% ', ' UNLESS loop.last() %][% END %] -
+[% END %]
+<h2>[% 'Tags cloud' | i18n | html %]</h2>
+
+[% IF all_sorted_tags.size() > 0 %]
+[% FOREACH t IN all_sorted_tags %][% t.category %]::[% t.tag_label %] ([% t.nb_groups %])[% ', ' UNLESS loop.last() %][% END %] -
+[% END %]