Changeset 1762


Ignore:
Timestamp:
2/8/2010 5:51:37 AM (4 years ago)
Author:
lowjoel
Message:

Do not unset and reset the superseded field of the table as that re-enables downloads which have been superseded in the database only.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/website/scripts/downloads.php

    r1760 r1762  
    278278        //Ensure that only 3 builds are not superseded at any one time. 
    279279        mysql_query('START TRANSACTION'); 
     280         
     281        //Get the latest 3 builds and concatenate them into a MySQL set. 
     282        $builds = array(); 
     283        $query = mysql_query(sprintf('SELECT builds.DownloadID FROM builds 
     284            INNER JOIN downloads ON builds.DownloadID=downloads.DownloadID 
     285            WHERE Branch=\'%s\' AND Superseded=0 
     286            ORDER BY builds.DownloadID DESC LIMIT 3', mysql_real_escape_string($branch))); 
     287        while (($row == mysql_fetch_array($query)) !== false) 
     288            $builds[] = intval($row['DownloadID']); 
     289        $ignoredBuilds = implode(', ', $builds); 
     290         
     291        //Set the builds which aren't yet superseded and not in the latest 3 builds 
     292        //as superseded. 
    280293        mysql_query(sprintf('UPDATE downloads SET Superseded=1 
    281294            WHERE DownloadID IN ( 
    282                 SELECT DownloadID FROM builds where Branch=\'%s\' 
     295                SELECT DownloadID FROM builds 
     296                    WHERE Branch=\'%s\' AND 
     297                    Superseded=0 AND 
     298                    DownloadID NOT IN (%s) 
    283299            )', 
    284             mysql_real_escape_string($branch))); 
    285         mysql_query(sprintf('UPDATE downloads SET Superseded=0 
    286             WHERE DownloadID IN ( 
    287                 SELECT DownloadID FROM builds where Branch=\'%s\' 
    288             ) 
    289             ORDER BY DownloadID DESC 
    290             LIMIT 3', mysql_real_escape_string($branch))); 
     300            mysql_real_escape_string($branch), $ignoredBuilds)); 
    291301        mysql_query('COMMIT'); 
    292302        return $buildId; 
Note: See TracChangeset for help on using the changeset viewer.