Difference between revisions of "Stats Design"

From Dreamwidth Notes
Jump to: navigation, search
m (Add category)
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This is a a loosely organized collection of notes and links for the Stats feature design. (Note: this is for the new stats system only - there's an existing legacy system too.)
+
{{Update}}
  
[http://bugs.dwscoalition.org/show_bug.cgi?id=2717 Bug 2717] and its dependent bugs
+
This is a a loosely organized collection of notes and links for the Stats feature design. (Note: this is for the new stats system only - there's an existing legacy system too.)
  
 
[[Project_Teams#Site_statistics|Stats project team]]
 
[[Project_Teams#Site_statistics|Stats project team]]
Line 29: Line 29:
 
== Storing and retrieving statistics ==
 
== Storing and retrieving statistics ==
  
[http://hg.dwscoalition.org/dw-free/file/tip/cgi-bin/DW/StatStore.pm DW::StatStore]
+
[https://github.com/dreamwidth/dw-free/blob/develop/cgi-bin/DW/StatStore.pm DW::StatStore]
  
 
== Statistics items ==
 
== Statistics items ==
  
* [http://hg.dwscoalition.org/dw-free/file/tip/cgi-bin/DW/StatData.pm DW::StatData]
+
* [https://github.com/dreamwidth/dw-free/blob/develop/cgi-bin/DW/StatData.pm DW::StatData]
* [http://hg.dwscoalition.org/dw-free/file/tip/cgi-bin/DW/StatData/ DW::StatData::*]
+
* [https://github.com/dreamwidth/dw-free/blob/develop/cgi-bin/DW/StatData/ DW::StatData::*]
  
 
== Collecting statistics ==
 
== Collecting statistics ==
Line 40: Line 40:
 
This works by massaging, aggregating, and or compiling (as appropriate) data from various places and storing the results using DW::StatStore.
 
This works by massaging, aggregating, and or compiling (as appropriate) data from various places and storing the results using DW::StatStore.
  
1. [http://hg.dwscoalition.org/dw-free/file/tip/etc/stats-collection.conf etc/stats-collection.conf] should contain something like:
+
1. [https://github.com/dreamwidth/dw-free/blob/develop/etc/stats-collection.conf etc/stats-collection.conf] should contain something like:
 
<source lang="text">## collect and store all stats under the accounts category
 
<source lang="text">## collect and store all stats under the accounts category
 
## hangs if you don't enclose the asterisk in quotes
 
## hangs if you don't enclose the asterisk in quotes
Line 51: Line 51:
 
</source>
 
</source>
  
2. [http://hg.dwscoalition.org/dw-free/file/tip/bin/worker/stats-collection bin/worker/stats-collection] is the utility that handles stats collection. Run at least once per 24 hours, either from your crontab or by listing it in [http://hg.dwscoalition.org/dw-free/file/tip/etc/workers.conf etc/workers.conf].
+
2. [https://github.com/dreamwidth/dw-free/blob/develop/bin/worker/stats-collection bin/worker/stats-collection] is the utility that handles stats collection. Run at least once per 24 hours, either from your crontab or by listing it in [https://github.com/dreamwidth/dw-free/blob/develop/etc/workers.conf etc/workers.conf].
  
3. (only needed if you chose to use [http://hg.dwscoalition.org/dw-free/file/tip/etc/workers.conf etc/workers.conf]): add a line to the "all" section reading:
+
3. (only needed if you chose to use [https://github.com/dreamwidth/dw-free/blob/develop/etc/workers.conf etc/workers.conf]): add a line to the "all" section reading:
 
<source lang="text">  stats-collection: 1
 
<source lang="text">  stats-collection: 1
 
</source>(note: this is for development only, as it assumes you only have one server - in production environments, you will usually list it in the section for a specific server)
 
</source>(note: this is for development only, as it assumes you only have one server - in production environments, you will usually list it in the section for a specific server)
Line 59: Line 59:
 
== Displaying statistics ==
 
== Displaying statistics ==
  
* [http://hg.dwscoalition.org/dw-free/file/tip/htdocs/stats/ htdocs/stats/*] (public stats)
+
* [https://github.com/dreamwidth/dw-free/blob/develop/views/stats/site.tt views/stats/site.tt] (public stats)
* [http://hg.dwscoalition.org/dw-free/file/tip/htdocs/admin/stats.bml htdocs/admin/stats.bml] (restricted stats)
+
* [https://github.com/dreamwidth/dw-free/blob/develop/views/admin/stats.tt views/admin/stats.tt] (restricted stats)
 
+
* [https://github.com/dreamwidth/dw-free/blob/develop/cgi-bin/DW/Controller/SiteStats.pm DW::Controller::SiteStats.pm] (the stats page controller for both public and restricted stats)
(note: as of June 19 there is an [http://bugs.dwscoalition.org/attachment.cgi?id=3716 uncommitted patch] on [http://bugs.dwscoalition.org/show_bug.cgi?id=124 bug 124] [[Routing_and_Template_Toolkit|TTizing]] the stats display to DW::Controller::SiteStats, views/admin/stats.tt, view/site/stats.tt)
+
* [https://github.com/dreamwidth/dw-free/blob/develop/cgi-bin/DW/Controller/Graphs.pm DW::Controller::Graphs.pm] (the stats graphs controller for both public and restricted stats)
  
 
[[Category: Development]]
 
[[Category: Development]]

Latest revision as of 10:08, 4 August 2014

Needs Update: This page has been found in need of an update. Information may be wrong or outdated!

This is a a loosely organized collection of notes and links for the Stats feature design. (Note: this is for the new stats system only - there's an existing legacy system too.)

Stats project team

Table definitions

CREATE TABLE statkeylist (
    statkeyid INT UNSIGNED NOT NULL AUTO_INCREMENT, 
    name VARCHAR(255) DEFAULT NULL, 
 
    PRIMARY KEY (statkeyid), 
    UNIQUE KEY (name) 
)
 
CREATE TABLE site_stats ( 
    category_id INT UNSIGNED NOT NULL, 
    key_id INT UNSIGNED NOT NULL, 
    insert_time INT UNSIGNED NOT NULL, 
    VALUE INT UNSIGNED NOT NULL, 
 
    -- FIXME: This is good for retrieving data for a single category+key, but 
    -- maybe not as good if we want all keys for the category, with a limit on 
    -- time (ie, last 5 entries, or last 2 weeks). Do we need an extra index? 
    INDEX (category_id, key_id, insert_time) 
)

Storing and retrieving statistics

DW::StatStore

Statistics items

Collecting statistics

This works by massaging, aggregating, and or compiling (as appropriate) data from various places and storing the results using DW::StatStore.

1. etc/stats-collection.conf should contain something like:

## collect and store all stats under the accounts category
## hangs if you don't enclose the asterisk in quotes
# accounts: "*"
## collect and store only these stats under the accounts category
# accounts: [ identity, personal, redirect ]
accounts: "*"
active: "*"
paid: "*"

2. bin/worker/stats-collection is the utility that handles stats collection. Run at least once per 24 hours, either from your crontab or by listing it in etc/workers.conf.

3. (only needed if you chose to use etc/workers.conf): add a line to the "all" section reading:

  stats-collection: 1
(note: this is for development only, as it assumes you only have one server - in production environments, you will usually list it in the section for a specific server)

Displaying statistics