unknownplace.org

前の日 | 最新のメモ | 次の日

# 2006-08-01

退社。

はかそん

定期的にやるのいいなぁ。

plaggerとか動き出すとあまり弄らなくなるから、そういう時間を作るという意味でもいい。

書いた

WWW::Blog::Metadata

Typepadのfeed数が変ったせいかテストこける。

--- t/01-extract.t.orig 2006-08-01 14:32:46.448523382 +0900
+++ t/01-extract.t      2006-08-01 14:32:02.566356991 +0900
@@ -28,7 +28,7 @@
 $meta = WWW::Blog::Metadata->extract_from_uri('http://btrott.typepad.com/');
 ok($meta);
 ok($meta->feeds);
-is(scalar @{ $meta->feeds }, 2);
+is(scalar @{ $meta->feeds }, 3);
 is($meta->feeds->[0], 'http://btrott.typepad.com/typepad/atom.xml');
 is($meta->feeds->[1], 'http://btrott.typepad.com/typepad/index.rdf');
 is($meta->foaf_uri, 'http://btrott.typepad.com/foaf.rdf');

うーむ、こういうテストの書き方はどうなんだ。RTかいとくか。

出社。

rate 5 or 4 の未読数だけ表示。すごく適当。

#!/usr/bin/env perl

use strict;
use warnings;
use FindBin;
use File::Spec;
use lib File::Spec->catfile( $FindBin::Bin, 'lib' );

use List::Util qw/first/;
use Plagger::Schema::SQLite;

my $schema = Plagger::Schema::SQLite->connect( 'dbi:SQLite:/home/typester/workdir/plagger/plagger.db' );
$schema->storage->on_connect_do( ['PRAGMA synchronous = OFF'] );

$| = 1;
while (1) {
    my @rates = $schema->resultset('Feed')->search(
        { 'entries.read' => 0 },
        {   join            => [qw/entries/],
            group_by        => [qw/me.rate/],
            include_columns => ['count(*)'],
            order_by        => 'me.rate DESC',
        }
    )->all;

    print 'Plagger(';
    for my $rate ( reverse 4 .. 5 ) {
        my $data = first { $rate eq $_->rate } @rates;

        print $data
            && defined $data->get_column('count(*)')
            ? $data->get_column('count(*)')
            : '0';
        print ',' unless $rate == 4;
    }
    print ") \n";

    sleep 60;
}

comments


Fork me on GitHub