Download & Extend

Seeders and Leechers statistics NEVER update

Project:BitTorrent
Version:5.x-2.0-beta3
Component:Code
Category:bug report
Priority:normal
Assigned:bradfordcp
Status:closed (won't fix)

Issue Summary

My site is now been up for about 3 weeks, people been downloading and seeding since. But not on any one occasion have I seen the Seeders & Leechers stats change from the default zero.

I have run cron on various occasions but still these don't update, what could be the course?

Comments

#1

Component:User interface» Code
Assigned to:Anonymous» bradfordcp

I am not sure, I will look into the queries tonight or tomorrow, be sure to check your interval values. It doesn't matter how many times you run cron, if the interval hasn't passed it will not update. Also try deleting the variable "bt_tracker_last_regen" or look more closely at your pruning interval.

If you are interested, all of the stats update logic is in the last function at http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/bittorrent/...

or

<?php
/**
* Implementation of hook_cron.
*/
function bt_tracker_cron() {
 
$last_prune = variable_get('bt_tracker_last_prune', 0);
 
  if (
time() - $last_prune > variable_get('bt_tracker_prune_interval', 3600)) {       
   
db_query("DELETE FROM {bt_tracker_active_users} WHERE last_announce < %d", $last_prune);
   
variable_set('bt_tracker_last_prune', time());
  }
 
 
$last_regen = variable_get('bt_tracker_last_regen', 0);
  if (
time() - $last_regen > variable_get('bt_tracker_stats_interval', 3600)) {
   
// Update the statistics for the torrent based off of the active users table
    // Update the seeders first
   
$result = db_query("SELECT bt.info_hash, COUNT(btau.ip) AS seeders FROM {bt_torrents} bt INNER JOIN {bt_tracker_active_users} btau ON btau.info_hash = bt.info_hash WHERE btau.bytes_left = 0 GROUP BY bt.info_hash");
    while (
$row = db_fetch_array($result)) {
     
db_query("UPDATE {bt_torrents} bt SET seeders = %d WHERE info_hash = %b", $row['seeders'], $row['info_hash']);
    }
   
   
$result = db_query("SELECT bt.info_hash, COUNT(btau.ip) AS seeders FROM {bt_torrents} bt LEFT JOIN {bt_tracker_active_users} btau ON btau.info_hash = bt.info_hash WHERE NOT btau.bytes_left = 0 OR btau.ip IS NULL GROUP BY bt.info_hash");
    while (
$row = db_fetch_array($result)) {
     
db_query("UPDATE {bt_torrents} bt SET seeders = %d WHERE info_hash = %b", $row['seeders'], $row['info_hash']);
    }
   
   
// Update the leechers
   
$result = db_query("SELECT bt.info_hash, COUNT(btau.ip) AS leechers FROM {bt_torrents} bt INNER JOIN {bt_tracker_active_users} btau ON btau.info_hash = bt.info_hash WHERE NOT btau.bytes_left = 0 GROUP BY bt.info_hash");
    while (
$row = db_fetch_array($result)) {
     
db_query("UPDATE {bt_torrents} bt SET leechers = %d WHERE info_hash = %b", $row['leechers'], $row['info_hash']);
    }
   
   
$result = db_query("SELECT bt.info_hash, COUNT(btau.ip) AS leechers FROM {bt_torrents} bt LEFT JOIN {bt_tracker_active_users} btau ON btau.info_hash = bt.info_hash WHERE btau.bytes_left = 0 OR btau.ip IS NULL GROUP BY bt.info_hash");
    while (
$row = db_fetch_array($result)) {
     
db_query("UPDATE {bt_torrents} bt SET leechers = %d WHERE info_hash = %b", $row['leechers'], $row['info_hash']);
    }
   
   
variable_set('bt_tracker_last_regen', time());
  }

}
?>

On a side note I was looking at scraping that part of the system in favor of live stats, what are your thoughts? They would be a bit more DB intensive, but you would be assured that all of the data is completely up to date.

#2

Up to date data is more preferable. because, I have been having some of my users saying, "I didn't download the torrent file due to no seeders or leechers", yet I have 2 PCs, one seeding and one leeching.

You said stats are not based on cron runs, this contradicts with this

These settings control how often certain events occur within the tracker. This includes the announce and scrape intervals for the client as well as how often the tracker should auto-prune the active users information. Please note that how often the code is executed depends on when your cron jobs run

What do you think is a suitable interval?

#3

The contradiction is due to bad wording on my part. I am trying to convey that the stats are not updated every cron run, instead they are updated during cron after a set interval has passed. I think to get the most up to date stats you should set the interval to be the same as your cron interval.

#4

Status:active» closed (won't fix)

5.x version is longer not supported.

nobody click here