Last active
August 29, 2015 14:01
-
-
Save jsutterfield/e6ff210d3cbd792dc83f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class reportTotalVideosOnWikia { | |
const LOG_FILE = '/tmp/reportTotalVideosOnWikiaAll.csv'; | |
public static function run ( $db, $test = false, $verbose = false, $params ) { | |
$dbname = $params['dbname']; | |
// Get a count of all videos grouped by provider on this wiki | |
$sql = "select provider, count(*) as total_videos | |
from video_info | |
where removed = 0 | |
group by provider;"; | |
if ( $verbose ) { | |
echo "Running on $dbname\n"; | |
} | |
$res = $db->query( $sql ); | |
while ( $row = $db->fetchRow( $res ) ) { | |
// Construct csv line in the form of "provider,video_count,db_name" | |
$provider = $row['provider']; | |
$total_videos = $row['total_videos']; | |
$msg = "$provider,$total_videos,$dbname\n"; | |
if ( !$test ) { | |
file_put_contents( self::LOG_FILE, $msg, FILE_APPEND ); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment