Scoop -- the swiss army chainsaw of content management
Front Page · Everything · News · Code · Help! · Wishlist · Project · Scoop Sites · Dev Notes · Latest CVS changes · Development Activities
SQL statements for some usage statistics New Code
By theantix , Section Code []
Posted on Tue Jul 22, 2003 at 12:00:00 PM PST
As a scoop admin, you might be interested to see how your users are using your site.  I wrote these SQL statements to check up on the users on my site, but I thought perhaps there might be some general interest from other admins, so here are some SQL statements that you can try out yourself.

All you should need to run these statements is a mysql prompt or phpmyadmin access.  Cut/Paste the query in and see who's using/abusing your site.

Without further adieu:

Most Stories:

select count(sid) as c_sid, aid from stories group by aid order by c_sid desc limit 10;

Most/Longest Stories:   

select sum(length(bodytext) + length(introtext)) as length, aid from stories group by aid order by length desc limit 10;

Most Comments:

select count(c.sid) as c_sid, u.nickname from comments c, users u where u.uid=c.uid group by c.uid order by c_sid desc  limit 10;

Most/Longest comments:

select sum(length(c.comment)) as length, u.nickname from comments c, users u where u.uid=c.uid group by c.uid order by length desc limit 10;

Read the most stories:

select count(v.sid) as c_sid, u.nickname from viewed_stories v, users u where v.uid=u.uid group by v.uid order by c_sid desc limit 10;

Read most comments:

select sum(v.lastseen) as s_seen, u.nickname from viewed_stories v, users u where v.uid=u.uid group by v.uid order by s_seen desc limit 10;

Busiest comment raters:

select count(cr.sid) as c_sid, u.nickname from commentratings cr, users u where cr.uid=u.uid group by cr.uid order by c_sid desc limit 10;

"Grumpiest" raters:

select count(cr.sid) as c_sid, cr.rating, u.nickname from commentratings cr, users u where cr.uid=u.uid and cr.rating=1 group by cr.uid, cr.rating order by c_sid desc, rating asc limit 10;

"Happiest" comment raters:

select count(cr.sid) as c_sid, cr.rating, u.nickname from commentratings cr, users u where cr.uid=u.uid and cr.rating=5 group by cr.uid, cr.rating order by c_sid desc, rating asc limit 10;

Best Rated:

select avg(c.points) as avg_rating, u.nickname from comments c, users u where c.uid=u.uid group by c.uid order by avg_rating desc limit 10;

Busiest Voters:

select count(p.qid) as c_votes, u.nickname from pollvoters p, users u where p.uid=u.uid group by p.uid order by c_votes desc limit 10;

Most popular poll options:

select aid as poll_item, avg(votes) as avg_votes from pollanswers group by aid order by poll_item limit 10;

< Gauntlet.ca underway | Scoop Install on OpenBSD 3.3 Problem: DBD::mSQL >

Menu
· create account
· faq
· search
· report bugs
· Scoop Administrators Guide
· Scoop Box Exchange

Login
Make a new account
Username:
Password:

Poll
Usage stats?
· Thanks 66%
· No Thanks 0%
· - 0%
· theantix was here 33%

Votes: 3
Results | Other Polls

Related Links
· Scoop
· More on New Code
· Also by theantix

Story Views
  30 Scoop users have viewed this story.

Display: Sort:
SQL statements for some usage statistics | 0 comments ( topical, 0 hidden)
Display: Sort:

Hosted by ScoopHost.com Powered by Scoop
All trademarks and copyrights on this page are owned by their respective companies. Comments are owned by the Poster. The Rest © 1999 The Management

create account | faq | search