Wizzup?
2009-04-14 19:32:39
There are roughly three options:
- "Old System" Keep the old system's way of storing data. (I will rewrite it from scratch, but we would roughly keep the same kind of database and stats.) The old system just has one entry for each user and script, and increases variables in there. There is no history function whatsoever. Every entry overrides all the previous ones. Although they usually just increase. ;) This system is of course compatible with the old one.
- "Extended System" Use a whole new sort of database, that log just about every possible thing that can be logged, and will be able to turn them into very interesting graphs. (It will log everything per user, randoms, variables, what script, etc.) The system will use alot more DB space. (That shouldn't a be a problem?) My main objection again this system is when people would want a HTML interface to view stats. The load for viewing pages would probably be a bit higher than the old system, forcing caching of files. This would be quite hard to implement. Also, because the Extended system has much more features, making PHP/HTML code for all the different results it can display would take time. This system will also be backwards compatible with the old system, it will even be able to 'remove' history every month, so the database space would be about the same as the old one on the beginning of every month. (I hope I won't need to use this 'history whiper'.) Also note that it only removes 'history', not actual minutes or other numbers, only when they were committed and such. This is a small file I made, it contains some of the actions the system would have. It is probably not clear to you at all, it was to me when I wrote it though…
main:
-> default
-> Top X users -> users -> default
-> Top Y scripts -> scripts -> default
-> Total Time
-> Total events -> events -> default
-> Total variables -> variables -> default
special:
-> Randoms Statistics: All randoms, Failed/Solved.
script:
-> default stats
-> top X users -> users -> script
-> random events -> users -> randoms
-> script variables. users -> script variables
-> Detailed stats
-> All users. -> Users -> Script -> X
-> Sort by:
-> Time -> Idem
-> Event(s) -> Idem
-> Variables -> Idem
user:
-> default stats
-> Random events -> Users -> Randoms
-> Variables -> Users -> Variables
-> Script ownership -> Script -> Default
-> Scripts used, User.
-> Total stats rank. (X out of Y) -> Main -> Top X users ->
-> Extended stats
-> Failed Random Events / Solved -> Users -> Randoms -> Detailed stats.
-> Variables per hour -> Variables -> Detailed stats
-> User Stats for a certain script
-> Total Randoms & Variables
-> Total time
-> Rank at the script.
randoms && variables:
-> default stats
-> Total
-> Detailed stats
-> 10 users who have the variable || random the most.
-> 10 scripts who have the variable || random the most.
-> Randoms: Solved versus Failed
-> Variables: Average per hour.
-> Main
-> Most gotten event
-> Event with highest and lowest solving rate.
Database skeleton (I left a few inserted values in there):
-- phpMyAdmin SQL Dump
-- version 2.11.8.1deb1
-- [url]http://www.phpmyadmin.net[/url]
--
-- Host: localhost
-- Generation Time: Apr 15, 2009 at 12:29 AM
-- Server version: 5.0.67
-- PHP Version: 5.2.6-2ubuntu4.1
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- Database: `wizstats`
--
-- --------------------------------------------------------
--
-- Table structure for table `base_randoms_scripts`
--
CREATE TABLE IF NOT EXISTS `base_randoms_scripts` (
`RandomID` mediumint(5) unsigned NOT NULL,
`ScriptID` mediumint(5) unsigned NOT NULL,
`Amount` int(10) unsigned NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `base_randoms_scripts`
--
-- --------------------------------------------------------
--
-- Table structure for table `base_randoms_users`
--
CREATE TABLE IF NOT EXISTS `base_randoms_users` (
`RandomID` int(5) NOT NULL,
`UserID` int(8) NOT NULL,
`Amount` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `base_randoms_users`
--
-- --------------------------------------------------------
--
-- Table structure for table `base_scripts`
--
CREATE TABLE IF NOT EXISTS `base_scripts` (
`ID` mediumint(5) unsigned NOT NULL,
`Time_Seconds` int(11) unsigned NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `base_scripts`
--
-- --------------------------------------------------------
--
-- Table structure for table `base_users`
--
CREATE TABLE IF NOT EXISTS `base_users` (
`ID` mediumint(6) unsigned NOT NULL,
`Time_Seconds` int(11) unsigned NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `base_users`
--
INSERT INTO `base_users` (`ID`, `Time_Seconds`) VALUES
(1, 1002);
-- --------------------------------------------------------
--
-- Table structure for table `commits`
--
CREATE TABLE IF NOT EXISTS `commits` (
`CommitID` int(10) unsigned NOT NULL auto_increment,
`UserID` mediumint(6) unsigned NOT NULL,
`ScriptID` int(4) unsigned NOT NULL,
`Time_Seconds` int(10) unsigned NOT NULL,
`Date_Time_Commited` timestamp NOT NULL default CURRENT_TIMESTAMP,
PRIMARY KEY (`CommitID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;
--
-- Dumping data for table `commits`
--
INSERT INTO `commits` (`CommitID`, `UserID`, `ScriptID`, `Time_Seconds`, `Date_Time_Commited`) VALUES
(1, 1, 1, 15, '2009-02-25 21:25:53'),
(2, 1, 1, 9, '2009-02-25 21:26:10'),
(3, 1, 2, 588, '2009-02-27 01:14:59'),
(4, 2, 2, 1337, '2009-02-27 01:15:25'),
(5, 2, 1, 12, '2009-02-27 01:15:37');
-- --------------------------------------------------------
--
-- Table structure for table `commit_vars`
--
CREATE TABLE IF NOT EXISTS `commit_vars` (
`CommitID` int(11) unsigned NOT NULL,
`RandomID` mediumint(5) unsigned NOT NULL,
`Amount` mediumint(9) unsigned NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `commit_vars`
--
INSERT INTO `commit_vars` (`CommitID`, `RandomID`, `Amount`) VALUES
(1, 1, 2),
(2, 2, 1),
(2, 1, 1),
(3, 4, 12),
(4, 2, 33),
(5, 5, 52),
(2, 6, 3),
(1, 11, 63);
-- --------------------------------------------------------
--
-- Table structure for table `custom_random`
--
CREATE TABLE IF NOT EXISTS `custom_random` (
`ID` mediumint(5) unsigned NOT NULL auto_increment,
`Name` varchar(30) NOT NULL,
`is_var` tinyint(1) NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=12 ;
--
-- Dumping data for table `custom_random`
--
INSERT INTO `custom_random` (`ID`, `Name`, `is_var`) VALUES
(1, 'Mysterious Box', 0),
(2, 'Sandwich Lady', 0),
(3, 'Trades', 0),
(4, 'Frog Events', 0),
(5, 'Drill Demon', 0),
(6, 'Maze', 0),
(7, 'Quiz', 0),
(8, 'Scaperune Balloons', 0),
(9, 'Pinball', 0),
(10, 'Scaperune Island', 0),
(11, 'Essence', 1);
-- --------------------------------------------------------
--
-- Table structure for table `scripts`
--
CREATE TABLE IF NOT EXISTS `scripts` (
`ID` int(5) NOT NULL,
`OwnerID` mediumint(9) NOT NULL,
`Name` varchar(40) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `scripts`
--
INSERT INTO `scripts` (`ID`, `OwnerID`, `Name`) VALUES
(1, 1, 'Wizzup''s First Script!'),
(2, 1, 'Wizzup''s Second Script!');
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE IF NOT EXISTS `users` (
`ID` mediumint(8) unsigned NOT NULL auto_increment,
`Name` varchar(20) NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`ID`, `Name`) VALUES
(1, 'Wizzup?'),
(2, 'Widget');
This is a rather simple query that finds all the random events and variables that each script has.
mysql> select custom_random.name, scripts.name, sum(commit_vars.amount) from commit_vars inner join custom_random on commit_vars.randomid = custom_random.id inner join commits on commit_vars.commitid = commits.commitid inner join scripts on commits.scriptid = scripts.id group by custom_random.name, scripts.id;
+----------------+-------------------------+-------------------------+
| name | name | sum(commit_vars.amount) |
+----------------+-------------------------+-------------------------+
| Drill Demon | Wizzup's First Script! | 52 |
| Essence | Wizzup's First Script! | 63 |
| Frog Events | Wizzup's Second Script! | 12 |
| Maze | Wizzup's First Script! | 3 |
| Mysterious Box | Wizzup's First Script! | 3 |
| Sandwich Lady | Wizzup's First Script! | 1 |
| Sandwich Lady | Wizzup's Second Script! | 33 |
+----------------+-------------------------+-------------------------+
7 rows in set (0.00 sec)
I personally like the Extended System the most, but I don't know how practical it is, and I can't promise I will finish it in very near future. The other two Systems shouldn't be hard to make, and will take less time to create as well.
What do you guys and girls think?
EDIT: For graphs: http://pchart.sourceforge.net/index.php



