44 lines
1.1 KiB
Perl
Executable file
44 lines
1.1 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
#
|
|
# bin/schedule-copier-jobs
|
|
#
|
|
# A simple job that schedules copier tasks for the sphinx copier. This should
|
|
# be run whenever you want to clean up the database of new/old data. Probably
|
|
# no more often than once every few weeks.
|
|
#
|
|
# Authors:
|
|
# Mark Smith <mark@dreamwidth.org>
|
|
#
|
|
# Copyright (c) 2009 by Dreamwidth Studios, LLC.
|
|
#
|
|
# This program is free software; you may redistribute it and/or modify it under
|
|
# the same terms as Perl itself. For a copy of the license, please reference
|
|
# 'perldoc perlartistic' or 'perldoc perlgpl'.
|
|
#
|
|
|
|
use strict;
|
|
use v5.10;
|
|
|
|
BEGIN {
|
|
require "$ENV{LJHOME}/cgi-bin/ljlib.pl";
|
|
}
|
|
|
|
use DW::Task::SphinxCopier;
|
|
|
|
die "Need to have Sphinx search enabled.\n"
|
|
unless @LJ::SPHINX_SEARCHD;
|
|
|
|
my $dbr = LJ::get_db_reader() or die;
|
|
my $sth = $dbr->prepare( q{SELECT userid FROM user WHERE journaltype IN ('P','C')} );
|
|
$sth->execute;
|
|
|
|
while ( my ( $userid ) = $sth->fetchrow_array ) {
|
|
warn "Scheduling $userid ...\n";
|
|
DW::TaskQueue->dispatch(
|
|
DW::Task::SphinxCopier->new( {
|
|
userid => $userid,
|
|
source => 'schedule',
|
|
} )
|
|
);
|
|
select undef, undef, undef, 0.02;
|
|
}
|