Initial new site statistics page.
Patch by pauamma.
diffs (199 lines):
diff -r 1cf60d4ac4e7 -r 0c02bbf9f08f bin/upgrading/en.dat
--- a/bin/upgrading/en.dat Mon May 18 00:06:12 2009 +0000
+++ b/bin/upgrading/en.dat Mon May 18 00:13:33 2009 +0000
@@ -575,6 +575,8 @@ crumb.setpgpkey=Public Key
crumb.setpgpkey=Public Key
crumb.siteopts=Browse Preferences
+
+crumb.sitestats=Site Statistics
crumb.stats=Statistics
diff -r 1cf60d4ac4e7 -r 0c02bbf9f08f cgi-bin/DW/StatData/ActiveAccounts.pm
--- a/cgi-bin/DW/StatData/ActiveAccounts.pm Mon May 18 00:06:12 2009 +0000
+++ b/cgi-bin/DW/StatData/ActiveAccounts.pm Mon May 18 00:13:33 2009 +0000
@@ -20,8 +20,10 @@ DW::StatData::ActiveAccounts - Active ac
=head1 SYNOPSIS
+ my $stats_obj = DW::StatData::ActiveAccounts->new( %$data );
+
+ # Don't use in web context.
my $data = DW::StatData::ActiveAccounts->collect( @keys ); # See list below
- my $stats_obj = DW::StatData::ActiveAccounts->new( %$data );
An account is counted as active when it logs in, when it posts an entry (when
posting to a community, both the poster and the community are marked active),
diff -r 1cf60d4ac4e7 -r 0c02bbf9f08f cgi-bin/crumbs.pl
--- a/cgi-bin/crumbs.pl Mon May 18 00:06:12 2009 +0000
+++ b/cgi-bin/crumbs.pl Mon May 18 00:13:33 2009 +0000
@@ -71,6 +71,7 @@ use Errno qw(ENOENT);
'searchregion' => ['Search By Region', '/directory.bml', 'search'],
'seeoverrides' => ['View User Overrides', '', 'support'],
'setpgpkey' => ['Public Key', '/manage/pubkey.bml', 'manage'],
+ 'sitestats' => ['Site Statistics', '/stats/site.bml', 'about'],
'stats' => ['Statistics', '/stats.bml', 'about'],
'styles' => ['Styles', '/styles/', 'modify'],
'support' => ['Support', '/support/', 'home'],
diff -r 1cf60d4ac4e7 -r 0c02bbf9f08f htdocs/stats/site.bml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/htdocs/stats/site.bml Mon May 18 00:13:33 2009 +0000
@@ -0,0 +1,109 @@
+<?_c
+#
+# stats/site.bml
+#
+# New public statistics
+#
+# Authors:
+# Afuna <[email protected]>
+# Pau Amma <[email protected]>
+#
+# Copyright (c) 2009 by Dreamwidth Studios, LLC.
+#
+# This program is free software; you may redistribute it and/or modify it under
+# the same terms as Perl itself. For a copy of the license, please reference
+# 'perldoc perlartistic' or 'perldoc perlgpl'.
+#
+_c?><?page
+body<=
+
+<?_code
+{
+ use strict;
+ use warnings;
+ use vars qw/ $title /;
+
+ use DW::StatStore;
+ use DW::StatData;
+
+ LJ::ModuleLoader::autouse_subclasses( 'DW::StatData' );
+
+ LJ::need_res( 'stc/sitestats.css' );
+ LJ::set_active_crumb( 'sitestats' );
+
+ $title = BML::ml( '.title', { sitenameshort => $LJ::SITENAMESHORT } );
+
+ # number of accounts (total+by type)
+ my $accounts_by_type = DW::StatData::AccountsByType->load_latest(
DW::StatStore->get( "accounts" ) );
+ my $total; # Used in paid account stats below
+ my $ret = "<h2>$ML{'.accounts.title'}</h2>";
+
+ if ( defined $accounts_by_type ) {
+ $ret .= "<ul>";
+ $ret .= "<li>" . $ML{".accounts.bytype.$_"} . " "
+ . $accounts_by_type->value( $_ ) . "</li>"
+ foreach qw/ total personal identity /;
+ $ret .= "</ul>";
+ $total = $accounts_by_type->value( 'total' );
+ } else {
+ $ret .= $ML{'.error.notavailable'};
+ }
+
+ # number of active accounts (by time since last active)
+ my $active_accounts = DW::StatData::ActiveAccounts->load_latest(
DW::StatStore->get( "active" ) );
+ my $active; # Used in paid account stats below
+ $ret .= "<h2>$ML{'.active.title'}</h2><p>$ML{'.active.desc'}</p>";
+
+ if ( defined $active_accounts ) {
+ $ret .= "<ul>";
+ $ret .= "<li>" . $ML{".active.bytime.$_"} . " "
+ . $active_accounts->value( $_ ) . "</li>"
+ foreach qw/ active_1d active_7d active_30d /;
+ $ret .= "</ul>";
+ $active = $active_accounts->value( 'active_30d' );
+ } else {
+ $ret .= $ML{'.error.notavailable'};
+ }
+
+ # Paid accounts (by level), with % of total and active
+ my $paid = DW::StatData::PaidAccounts->load_latest( DW::StatStore->get(
"paid" ) );
+ $ret .= "<h2>$ML{'.paid.title'}</h2>";
+
+ if ( defined $paid ) {
+ $ret .= "<table><tr>";
+ $ret .= "<th>" . $ML{".paid.colhdr.$_"} . "</th>"
+ foreach qw/ level number pct_total pct_active /;
+ $ret .= "</tr>\n";
+ foreach my $level ( qw( paid premium seed ) ) {
+ $ret .= "<tr><th>" . $ML{".paid.rowhdr.$level"} . "</th>";
+ my $n = $paid->value( $level );
+ $ret .= "<td class='stats'>$n</td>";
+ $ret .= "<td class='stats'>"
+ . ( defined $total ? int( 100 * $n / $total ) : "" )
+ . "</td>";
+ $ret .= "<td class='stats'>"
+ . ( defined $active ? int( 100 * $n / $active ) : "" )
+ . "</td></tr>\n";
+ }
+ $ret .= "</table>";
+ } else {
+ $ret .= $ML{'.error.notavailable'};
+ }
+
+# FIXME: remove this when you have implemented them all
+#
+# * Number of accounts, total DONE
+# * Number of accounts active DONE
+# * Number of paid accounts (by payment level) DONE
+# -- as a percentage of total accounts DONE
+# -- as a percentage of active accounts DONE
+# -- xxx number of active paid accounts
+# -- xxx number of inactive paid accounts
+
+ return $ret;
+}
+_code?>
+
+<=body
+title=><?_code return $title; _code?>
+page?>
diff -r 1cf60d4ac4e7 -r 0c02bbf9f08f htdocs/stats/site.bml.text
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/htdocs/stats/site.bml.text Mon May 18 00:13:33 2009 +0000
@@ -0,0 +1,39 @@
+;; -*- coding: utf-8 -*-
+
+.accounts.bytype.total=Total:
+
+.accounts.bytype.personal=Personal (users):
+
+.accounts.bytype.identity=External identity (OpenID, etc.):
+
+.accounts.title=Number of accounts
+
+.active.bytime.active_1d=Last 24 hours:
+
+.active.bytime.active_7d=Last 7 days:
+
+.active.bytime.active_30d=Last 30 days:
+
+.active.desc=These are accounts who logged in, posted an entry, commented, or
edited a comment during the period indicated. For entries posted to
communities, both the poster and the community are counted.
+
+.active.title=Active accounts
+
+.error.notavailable=(Sorry, those statistics aren't available right now.)
+
+.paid.colhdr.level=Level
+
+.paid.colhdr.number=Number
+
+.paid.colhdr.pct_total=% of total accounts
+
+.paid.colhdr.pct_active=% of active accounts
+
+.paid.rowhdr.paid=Paid
+
+.paid.rowhdr.premium=Premium
+
+.paid.rowhdr.seed=Seed
+
+.paid.title=Paid accounts
+
+.title=[[sitenameshort]] Site Statistics
diff -r 1cf60d4ac4e7 -r 0c02bbf9f08f htdocs/stc/sitestats.css
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/htdocs/stc/sitestats.css Mon May 18 00:13:33 2009 +0000
@@ -0,0 +1,1 @@
+.stats { text-align: right; }
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog