Skip to content

Instantly share code, notes, and snippets.

@jsutterfield
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsutterfield/e6ff210d3cbd792dc83f to your computer and use it in GitHub Desktop.
Save jsutterfield/e6ff210d3cbd792dc83f to your computer and use it in GitHub Desktop.
<?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