Oppaitime's version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

update_recently_uploaded_torrents_swarms.php 1.2KB

12345678910111213141516171819202122232425262728293031323334
  1. <?
  2. // peerupdate.php is apparently shit so this is a crappy bandaid to fix the problem of
  3. // all the cached "0 seeds" on the first search page from peerupdate missing the changes.
  4. // It used to be in a sandbox that I just ran whenever I saw something wrong with
  5. // the first search page, but it only takes like 7ms to run so it's scheduled now.
  6. $FrontPageQ = new SphinxqlQuery();
  7. $FrontPageQ->select('groupid, id, seeders')
  8. ->order_by('time', 'desc');
  9. $FrontPageQ->from('torrents, delta');
  10. $FrontPageQ->limit(0, 60, 60);
  11. $Results = $FrontPageQ->query()->to_array('id');
  12. $IDs = array();
  13. $Seeds = array();
  14. foreach ($Results as $i) {
  15. $GroupCache = $Cache->get_value('torrent_group_'.$i['groupid']);
  16. if (!$GroupCache) continue;
  17. $IDs = array_merge($IDs, array_column($GroupCache['d']['Torrents'], 'ID'));
  18. $Seeds = array_merge($Seeds, array_column($GroupCache['d']['Torrents'], 'Seeders'));
  19. }
  20. $QueryParts = array();
  21. for ($i = 0; $i < sizeof($IDs); $i++) {
  22. $QueryParts[] = '(ID='.$IDs[$i].' AND Seeders!='.$Seeds[$i].')';
  23. }
  24. $query = 'SELECT GroupID FROM torrents WHERE '.implode(' OR ', $QueryParts);
  25. $DB->query($query);
  26. if ($DB->has_results()) {
  27. foreach($DB->collect('GroupID') as $GID) {
  28. $Cache->delete_value('torrent_group_'.$GID);
  29. }
  30. }
  31. ?>