New importer, Nat. Geo. Wild.
[nonametv.git] / tools / nonametv-remove-old
blob34b10101d0c606b1bc33ab846c8817d1c099a195
1 #!/usr/bin/perl -w
3 use strict;
5 use NonameTV;
6 use NonameTV::DataStore;
7 use NonameTV::Config qw/ReadConfig/;
9 use Getopt::Long;
11 # Read configuration
12 my $conf = ReadConfig();
14 # Create Datastore
15 my $ds = NonameTV::DataStore->new( $conf->{DataStore} );
17 # print "Deleting old programs and batches from database\n";
18 $ds->sa->DoSql( "delete from programs where TO_DAYS(now()) - TO_DAYS(start_time) > 1" );
20 # print "Deleting batches\n";
22 # Retrieve a list of all batches with no matching programme.
23 my( $res, $sth ) = $ds->sa->Sql( "select batches.id, batches.name from batches left join programs on batches.id=programs.batch_id where programs.batch_id is null;" );
25 while( my $d = $sth->fetchrow_hashref() )
27 # print $d->{name} . "\n";
28 $ds->sa->Delete( 'batches', { id => $d->{id} } );