__section__
default
__description__

__title__

__page__
stats
__lang__
en_US
__name__
graphs
__template__
[% 

form.stats_days = form.stats_days || 1;
byweekavg = 0;
showtotal = 0;

mygraphs = [
	'Pages',
	'Hits',
	'Total Users',
	'Comments',
	'Page Bytes',
	'Total Bytes',
	'Section Pages',
	'Section Bytes',

	'Message Types',

	'Comment Scores',
	'Total Comments',
	'Total Comments By Source',
	'Comment IPIDs',
	'Total Moderations',
	'Total Metamoderations',

        'New Subscriptions',
        'Total Subscribers',
        'Total Renewing Subscribers',
        'Subscriber Pages',

	'RSS Pages',
	'Pages From RSS',
	'RSS UIDS',
	'From RSS UIDS',
	'RSS IPIDS',
	'From RSS IPIDS',
	
];


SWITCH gtitle;

  # Main Report
  CASE 'Pages';
  extra_pages = [];
  CALL extra_pages.splice(0, 0, constants.op_extras_countdaily);
  
  page_plugin = Slash.getObject('Slash::Page');
  IF page_plugin;
  	extra_pages.push("page");
  END;

  all_pages = ['total','index_page', 'comments_page', 'article_page'];
  section_pages = ['index_page', 'comments_page', 'article_page'];
  
  FOREACH cur_page = extra_pages;
	all_pages.push("${cur_page}_page");
	section_pages.push("${cur_page}_page");
  END;

  IF (form.stats_skid && form.stats_skid != 0);
      PROCESS make_graph
         showtotal => 1,
         skid   => form.stats_skid,
         type      => 'areastacked',
         statdata  => section_pages;
  ELSE;
      PROCESS make_graph
         skid   => 0,
         type      => 'areastackedindex',
         statdata  => all_pages;
  END;

  CASE 'Hits';
  IF (form.stats_skid && form.stats_skid != 0);
      %] <b>[% gtitle %]</b> graph for [% form.stats_skid %] is unavailable.
	Try the <b>Pages</b> graph instead.
     [%
#      PROCESS make_graph
#         showtotal => 1,
#         skid   => form.stats_skid,
#         type      => 'areastacked',
#         statdata  => ['rss_page', 'palm_page'];
  ELSE;
      PROCESS make_graph
         skid   => 0,
         type      => 'areastackedindex',
         statdata  => ['grand_total', 'rss_page', 'palm_page'];
  END;

  CASE 'Total Users';
  IF (form.stats_skid && form.stats_skid != 0);
      PROCESS make_graph
         skid   => form.stats_skid,
         type      => 'area',
         statdata  => ['ipids', 'users', 'users_subscriber'];
  ELSE;
      PROCESS make_graph
         skid   => 0,
         type      => 'area',
         statdata  => [['unique', '', 'ipids'],
                      ['unique_users', '', 'users']
                      ['users_subscriber', '', 'users_subscriber']
                     ];
  END;

  CASE 'Comments';
      PROCESS make_graph
         skid   => form.stats_skid || 0,
         type      => 'area',
         statdata  => ['comments'];

  CASE 'Page Bytes';
  IF (form.stats_skid && form.stats_skid != 0);
      PROCESS make_graph
         showtotal => 1,
         skid   => form.stats_skid,
         type      => 'areastacked',
         statdata  => ['index_bytes', 'article_bytes', 'comments_bytes'];
  ELSE;
      PROCESS make_graph
         skid   => 0,
         type      => 'areastackedindex',
         statdata  => ['total_bytes', 'index_bytes', 'article_bytes', 'comments_bytes'];
  END;

  CASE 'Total Bytes';
  IF (form.stats_skid && form.stats_skid != 0);
      PROCESS make_graph
         showtotal => 1,
         skid   => form.stats_skid,
         type      => 'areastacked',
         statdata  => ['index_bytes', 'article_bytes', 'comments_bytes', 'rss_bytes', 'palm_bytes'];
  ELSE;
      PROCESS make_graph
         skid   => 0,
         type      => 'areastackedindex',
         statdata  => ['grand_total_bytes', 'index_bytes', 'article_bytes', 'comments_bytes', 'rss_bytes', 'palm_bytes'];
  END;

  CASE 'Section Pages';
      avail_skins = Slash.db.getDescriptions('skins');
      sect_page = [];
      FOREACH skin = avail_skins.keys.sort;
         sect_page.push(['page', skin]);
      END;
      PROCESS make_graph
         type      => 'lines',
         statdata  => sect_page;

  CASE 'Section Bytes';
      avail_skins = Slash.db.getDescriptions('skins');
      sect_byte = [];
      FOREACH skid = avail_skins.keys.sort;
         sect_byte.push(['bytes', skid]);
      END;
      PROCESS make_graph
         type      => 'lines',
         statdata  => sect_byte;


  # Messages Report
  CASE 'Message Types';
      stats = Slash.getObject('Slash::Stats');
      skid => 0;

      stats_data_big = stats.getAllStats({ skid => skid, days => 1}).${skin};
      stats_data_key = stats_data_big.keys.sort.0;
      stats_data = stats_data_big.${stats_data_key};

      messages = Slash.getObject('Slash::Messages');
      codes = messages.getDescriptions("messagecodes");
      modes = messages.getDescriptions("deliverymodes");

      statdata = [];
      FOR code = codes.keys.nsort;
         # skip essentially unused modes 6, 8, 11 for Slashdot
         NEXT IF code == 6 || code == 8 || code == 11;
         statdata.push(["msg_$code", "", codes.$code]);
      END;

      PROCESS make_graph
         showtotal => 1,
         type      => 'areastacked'; 

  # Moderation Report
  CASE 'Comment Scores';
      PROCESS make_graph
         showtotal => 1,
         skid   => 0,
         type      => 'areastacked',
         statdata  => ['comments_score_5', 'comments_score_4', 'comments_score_3', 'comments_score_2', 'comments_score_1', 'comments_score_0', 'comments_score_-1'];

  CASE 'Total Comments';
      PROCESS make_graph
         skid   => 0,
         type      => 'area',
         statdata  => ['comments'];

  CASE 'Total Comments By Source';
      PROCESS make_graph
         skid   => 0,
         type      => 'areastacked',
         statdata  => ['comments_ipids_anononly', 'comments_ipids_loggedinonly', 'comments_ipids_anonandloggedin', 'comments_proxyanon'];

  CASE 'Comment IPIDs';
      PROCESS make_graph
         showtotal => 1,
         skid   => 0,
         type      => 'areastacked',
         statdata  => ['distinct_comment_ipids_anononly', 'distinct_comment_ipids_loggedinonly', 'distinct_comment_ipids_anonandloggedin'];

  CASE 'Total Moderations';
      PROCESS make_graph
         skid   => 0,
         type      => 'area',
         statdata  => ['m1_up_total', 'm1_down_total'];

  CASE 'Total Metamoderations';
      PROCESS make_graph
         skid   => 0,
         type      => 'area',
         statdata  => ['m2_fair_total', 'm2_unfair_total'];


  # Subscription Report
  CASE 'New Subscriptions';
      PROCESS make_graph
         showtotal => 1,
         skid   => 0,
         type      => 'areastacked',
         statdata  => ['subscribe_new_users', 'subscribe_renew_users'];

  CASE 'Total Subscribers';
      PROCESS make_graph
         byweekavg => 1,
         skid   => 0,
         type      => 'area',
         statdata  => ['subscribers_total', 'subscribers_current'];

  CASE 'Total Renewing Subscribers';
      PROCESS make_graph
         byweekavg => 1,
         skid   => 0,
         type      => 'area',
         statdata  => ['subscribers_renewing_total', 'subscribers_renewing_current'];

  CASE 'Subscriber Pages';
      PROCESS make_graph
         skid   => 0,
         type      => 'area',
         statdata  => ['total_subscriber', 'subscribe_hits_bought', 'total_secure'];

  CASE 'RSS Pages';
        avail_skins = Slash.db.getDescriptions('skins');
        sect_page = [];
        FOREACH skin = avail_skins.keys.sort;
           sect_page.push(['rss_page', skin]);
        END;
      PROCESS make_graph
         type      => 'lines',
         statdata  => sect_page;
  
  CASE 'Pages From RSS';
        avail_skins = Slash.db.getDescriptions('skins');
        sect_page = [];
        FOREACH skin = avail_skins.keys.sort;
           sect_page.push(['page_from_rss', skin]);
        END;
      PROCESS make_graph
         type      => 'lines',
         statdata  => sect_page;
  CASE 'RSS UIDS';
        avail_skins = Slash.db.getDescriptions('skins');
        sect_page = [];
        FOREACH skin = avail_skins.keys.sort;
           sect_page.push(['rss_uid', skin]);
        END;
      PROCESS make_graph
         type      => 'lines',
         statdata  => sect_page;
  CASE 'From RSS UIDS';
        avail_skins = Slash.db.getDescriptions('skins');
        sect_page = [];
        FOREACH skin = avail_skins.keys.sort;
           sect_page.push(['uid_from_rss', skin]);
        END;
      PROCESS make_graph
         type      => 'lines',
         statdata  => sect_page;
  CASE 'RSS IPIDS';
        avail_skins = Slash.db.getDescriptions('skins');
        sect_page = [];
        FOREACH skin = avail_skins.keys.sort;
           sect_page.push(['rss_ipid', skin]);
        END;
      PROCESS make_graph
         type      => 'lines',
         statdata  => sect_page;
  CASE 'From RSS IPIDS';
        avail_skins = Slash.db.getDescriptions('skins');
        sect_page = [];
        FOREACH skin = avail_skins.keys.sort;
           sect_page.push(['ipid_from_rss', skin]);
        END;
      PROCESS make_graph
         type      => 'lines',
         statdata  => sect_page;
  

  # default
  CASE;
      "";

END %]

__seclev__
1000
__version__
$Id$
