4 use vars qw($opt_j $opt_d);
7 use FS::UID qw(adminsuidsetup);
8 use FS::Record qw(qsearch qsearchs);
13 my $user = shift or die &usage;
16 my $start = shift or die &usage;
17 my $end = shift or die &usage;
19 $start = str2time($start) unless $start =~ /^(\d+)$/;
20 $end = str2time($end) unless $end =~ /^(\d+)$/;
22 my $extra_sql = "AND history_date >= $start AND history_date <= $end";
24 my $hashref = { 'history_action' => 'insert' };
26 $hashref->{'job'} = $opt_j if $opt_j;
28 my @h_queue = qsearch({
30 'hashref' => $hashref,
31 'extra_sql' => $extra_sql,
36 foreach my $h_queue (@h_queue) {
38 my @queue_args = qsearch({
39 'table' => 'h_queue_arg',
40 'hashref' => { 'history_action' => 'insert',
41 'jobnum' => $h_queue->jobnum,
43 'order_by' => 'argnum',
48 $arg =~ s/^db\.suicidegirls\.com$/sg-account/;
52 my $queue = new FS::queue {
53 map { $_ => $h_queue->$_() }
54 qw( job _date status statustext svcnum )
57 if ( $opt_d ) { #dry run
58 print "requeueing job: ". join(' ', @args). "\n";
59 my $error = $queue->check;
60 die "error requeueing job ". $h_queue->jobnum. ": $error" if $error;
62 print "requeueing job: ". join(' ', @args). "\n";
63 my $error = $queue->insert(@args);
64 #warn "error requeueing job ". $h_queue->jobnum. ": $error\n" if $error;
65 print "error requeueing job ". $h_queue->jobnum. ": $error\n" if $error;
72 print "requeued $num jobs\n";
75 die "Usage:\n\n freeside-history-requeue user start_timestamp end_timestamp\n";
80 freeside-history-requeue - Command line tool to re-trigger export jobs for existing services
84 freeside-history-requeue [ -j job ] [ -d ] user start_timestamp end_timestamp
88 Re-queues all queued jobs for the specified time period.
90 -j: specifies that only jobs with this job string are re-queued.
96 L<freeside-reexport>, L<freeside-sqlradius-reset>, L<FS::part_export>