Skip to content

Instantly share code, notes, and snippets.

@jsutterfield
Last active August 29, 2015 14:01
Show Gist options
  • Select an option

  • Save jsutterfield/e6ff210d3cbd792dc83f to your computer and use it in GitHub Desktop.

Select an option

Save jsutterfield/e6ff210d3cbd792dc83f to your computer and use it in GitHub Desktop.

Revisions

  1. jsutterfield revised this gist May 14, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion reportTotalVideosOnWikia.php
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    class reportTotalVideosOnWikia {

    const LOG_FILE = '/tmp/reportTotalVideosOnWikia.csv';
    const LOG_FILE = '/tmp/reportTotalVideosOnWikiaAll.csv';

    public static function run ( $db, $test = false, $verbose = false, $params ) {

  2. jsutterfield renamed this gist May 14, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. jsutterfield renamed this gist May 8, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. jsutterfield created this gist May 8, 2014.
    36 changes: 36 additions & 0 deletions gistfile1.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    <?php

    class reportTotalVideosOnWikia {

    const LOG_FILE = '/tmp/reportTotalVideosOnWikia.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 );
    }

    }
    }

    }