Gazelle/sections/tools/data/economic_stats.php

148 lines
6.1 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
/*
Tools necessary for economic management
1. Current overall stats (!economy)
2013-02-22 08:00:24 +00:00
2. Statistical traffic trends in a graph
2013-03-25 08:00:21 +00:00
a. All time / 1 year (whichever is smaller)
2011-03-28 14:21:28 +00:00
b. 1 month
c. 1 week
d. 1 day
3. Freeleech analysis
a. total download average during freeleech vs. normal conditions
b. total stats of a freeleech - uploaded torrents, upload amount, download amount, snatches, etc.
4. Traffic trends over an account's life, on average
a. at one week, one month, whatever (selectable range in weeks) - averages (up/down/ratio)
b. given a selected timespan, average ratio (users who are 4-5 months old have X ratio)
c. average date at which >50% of accounts with ratios >1 reach 1.0 and never dip below, stockpiling buffer
5. Raw numbers
a. total torrents, seeders, leechers
b. average seeds/leechs per torrent
c. average snatches/user
d. average seeding torrents/user
e. users on ratio watch
6. Distribution graph of seedership vs. torrent percentage
a. graph showing that the top 1% of torrents has 50% of seeders or whatever the numbers might be
7. Effects of economic changes
a. number of users changed by ratio being changed
b. project effects with intelligent mathematical analysis of a 24, 48 or 72 hour freeleech
*/
2013-05-02 08:00:23 +00:00
if (!check_perms('site_view_flow')) {
error(403);
}
2012-10-11 08:00:15 +00:00
View::show_header('Economy');
2011-03-28 14:21:28 +00:00
if (!$EconomicStats = $Cache->get_value('new_economic_stats')) {
2013-05-27 08:00:58 +00:00
$DB->query("
SELECT SUM(Uploaded), SUM(Downloaded), COUNT(ID)
FROM users_main
2013-07-04 08:00:56 +00:00
WHERE Enabled = '1'");
2011-03-28 14:21:28 +00:00
list($TotalUpload, $TotalDownload, $NumUsers) = $DB->next_record();
2013-05-27 08:00:58 +00:00
$DB->query("
SELECT SUM(Bounty)
FROM requests_votes");
2011-03-28 14:21:28 +00:00
list($TotalBounty) = $DB->next_record();
2013-05-27 08:00:58 +00:00
$DB->query("
SELECT SUM(rv.Bounty)
FROM requests_votes AS rv
2013-07-04 08:00:56 +00:00
JOIN requests AS r ON r.ID = rv.RequestID
WHERE TorrentID > 0");
2011-03-28 14:21:28 +00:00
list($AvailableBounty) = $DB->next_record();
2013-05-27 08:00:58 +00:00
$DB->query("
SELECT SUM(Snatched), COUNT(ID)
FROM torrents");
2011-03-28 14:21:28 +00:00
list($TotalSnatches, $TotalTorrents) = $DB->next_record(); // This is the total number of snatches for torrents that still exist
2013-07-04 08:00:56 +00:00
$DB->query("
SELECT COUNT(uid)
FROM xbt_snatched");
2011-03-28 14:21:28 +00:00
list($TotalOverallSnatches) = $DB->next_record();
2013-05-02 08:00:23 +00:00
if (($PeerStats = $Cache->get_value('stats_peers')) === false) {
2013-07-04 08:00:56 +00:00
$DB->query("
SELECT COUNT(fid)
FROM xbt_files_users
WHERE remaining = 0");
list($TotalSeeders) = $DB->next_record();
2013-07-04 08:00:56 +00:00
$DB->query("
SELECT COUNT(fid)
FROM xbt_files_users
WHERE remaining > 0");
list($TotalLeechers) = $DB->next_record();
} else {
list($TotalLeechers,$TotalSeeders) = $PeerStats;
}
$TotalPeers = $TotalLeechers + $TotalSeeders;
2013-05-02 08:00:23 +00:00
$DB->query("
SELECT COUNT(ID)
FROM users_main
2013-07-04 08:00:56 +00:00
WHERE (
SELECT COUNT(uid)
FROM xbt_files_users
WHERE uid = users_main.ID
) > 0");
2011-03-28 14:21:28 +00:00
list($TotalPeerUsers) = $DB->next_record();
$Cache->cache_value('new_economic_stats',
2013-07-04 08:00:56 +00:00
array($TotalUpload, $TotalDownload, $NumUsers, $TotalBounty,
$AvailableBounty, $TotalSnatches, $TotalTorrents,
$TotalOverallSnatches, $TotalSeeders, $TotalPeers,
2011-03-28 14:21:28 +00:00
$TotalPeerUsers), 3600);
} else {
2013-07-04 08:00:56 +00:00
list($TotalUpload, $TotalDownload, $NumUsers, $TotalBounty, $AvailableBounty,
$TotalSnatches, $TotalTorrents, $TotalOverallSnatches, $TotalSeeders,
$TotalPeers, $TotalPeerUsers) = $EconomicStats;
2011-03-28 14:21:28 +00:00
}
$TotalLeechers = $TotalPeers - $TotalSeeders;
?>
<div class="thin">
<div class="box">
<div class="head">Overall stats</div>
<div class="pad">
<ul class="stats nobullet">
2012-10-11 08:00:15 +00:00
<li><strong>Total upload: </strong><?=Format::get_size($TotalUpload)?></li>
<li><strong>Total download: </strong><?=Format::get_size($TotalDownload)?></li>
2013-05-02 08:00:23 +00:00
<li><strong>Total buffer: </strong><?=Format::get_size($TotalUpload - $TotalDownload)?></li>
2011-03-28 14:21:28 +00:00
<br />
2013-05-02 08:00:23 +00:00
<li><strong>Mean ratio: </strong><?=Format::get_ratio_html($TotalUpload, $TotalDownload)?></li>
<li><strong>Mean upload: </strong><?=Format::get_size($TotalUpload / $NumUsers)?></li>
<li><strong>Mean download: </strong><?=Format::get_size($TotalDownload / $NumUsers)?></li>
<li><strong>Mean buffer: </strong><?=Format::get_size(($TotalUpload - $TotalDownload) / $NumUsers)?></li>
2011-03-28 14:21:28 +00:00
<br />
2012-10-11 08:00:15 +00:00
<li><strong>Total request bounty: </strong><?=Format::get_size($TotalBounty)?></li>
<li><strong>Available request bounty: </strong><?=Format::get_size($AvailableBounty)?></li>
2011-03-28 14:21:28 +00:00
</ul>
</div>
</div>
<br />
<div class="box">
<div class="head">Swarms and snatches</div>
<div class="pad">
<ul class="stats nobullet">
<li><strong>Total seeders: </strong><?=number_format($TotalSeeders)?></li>
<li><strong>Total leechers: </strong><?=number_format($TotalLeechers)?></li>
2013-07-04 08:00:56 +00:00
<li><strong>Total peers: </strong><?=number_format($TotalSeeders + $TotalLeechers)?></li>
2011-03-28 14:21:28 +00:00
<li><strong>Total snatches: </strong><?=number_format($TotalOverallSnatches)?></li>
2013-07-04 08:00:56 +00:00
<li><strong>Seeder/leecher ratio: </strong><?=Format::get_ratio_html($TotalSeeders, $TotalLeechers)?></li>
<li><strong>Seeder/snatch ratio: </strong><?=Format::get_ratio_html($TotalSeeders, $TotalOverallSnatches)?></li>
2011-03-28 14:21:28 +00:00
<br />
2013-05-02 08:00:23 +00:00
<li><strong>Mean seeders per torrent: </strong><?=number_format($TotalSeeders / $TotalTorrents, 2)?></li>
<li><strong>Mean leechers per torrent: </strong><?=number_format($TotalLeechers / $TotalTorrents, 2)?></li>
<li><strong>Mean snatches per torrent: </strong><?=number_format($TotalSnatches / $TotalTorrents, 2)?></li>
2011-03-28 14:21:28 +00:00
<br />
2013-05-02 08:00:23 +00:00
<li><strong>Mean seeding per user: </strong><?=number_format($TotalSeeders / $NumUsers, 2)?></li>
<li><strong>Mean leeching per user: </strong><?=number_format($TotalLeechers / $NumUsers, 2)?></li>
<li><strong>Mean snatches per user: </strong><?=number_format($TotalOverallSnatches / $NumUsers, 2)?></li>
2011-03-28 14:21:28 +00:00
<br />
<li><strong>Total users in at least 1 swarm: </strong><?=number_format($TotalPeerUsers)?></li>
2013-05-02 08:00:23 +00:00
<li><strong>Mean seeding per user in at least 1 swarm: </strong><?=number_format($TotalSeeders / $TotalPeerUsers, 2)?></li>
<li><strong>Mean leeching per user in at least 1 swarm: </strong><?=number_format($TotalLeechers / $TotalPeerUsers, 2)?></li>
<li><strong>Mean snatches per user in at least 1 swarm: </strong><?=number_format($TotalSnatches / $TotalPeerUsers, 2)?></li>
2011-03-28 14:21:28 +00:00
</ul>
</div>
</div>
</div>
<?
2012-10-11 08:00:15 +00:00
View::show_footer();
2011-03-28 14:21:28 +00:00
?>