[Bast-commits] r7156 - ironman/plagger
castaway at dev.catalyst.perl.org
castaway at dev.catalyst.perl.org
Thu Jul 30 21:23:09 GMT 2009
Author: castaway
Date: 2009-07-30 21:23:09 +0000 (Thu, 30 Jul 2009)
New Revision: 7156
Added:
ironman/plagger/yaml_to_db.pl
Log:
Script to dump yaml subscriptions into db
Added: ironman/plagger/yaml_to_db.pl
===================================================================
--- ironman/plagger/yaml_to_db.pl (rev 0)
+++ ironman/plagger/yaml_to_db.pl 2009-07-30 21:23:09 UTC (rev 7156)
@@ -0,0 +1,34 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use YAML 'LoadFile';
+use Data::Dumper;
+use Data::UUID;
+use IronMan::Schema;
+
+my $yamlfile = shift;
+my $dsn = shift;
+my $yaml_dump = LoadFile($yamlfile);
+
+# my ($sub_dbi) = grep { $_->{module} eq 'Subscription::DBI' }
+# @{ $yaml_dump->{plugins} };
+# my $schema = IronMan::Schema->connect($sub_dbi->{config}{connect_info}->[0]);
+my $schema = IronMan::Schema->connect($dsn);
+
+my ($sub_conf) = grep { $_->{module} eq 'Subscription::Config' }
+ @{ $yaml_dump->{plugins} };
+print Dumper($sub_conf);
+my $feeds = $sub_conf->{config}{feed};
+
+my $uuid = Data::UUID->new();
+foreach my $feed (@$feeds) {
+ print "Feed: $feed->{url}\n";
+ my $fdb = $schema->resultset('Feed')->find_or_new({ id => $uuid->create_str, %$feed}, { key => 'url' });
+ if($fdb->in_storage) {
+ print "... already exists\n";
+ next;
+ }
+ $fdb->insert;
+}
+
More information about the Bast-commits
mailing list