summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2002-05-15 13:24:26 +0000
committerivan <ivan>2002-05-15 13:24:26 +0000
commiteb7c552dd8290d6b33a4e026c5dc21ebf01105cf (patch)
treef4e307c94039085b55bd2c416e78824cabe52911
parentce119821d508611bce8d2c62c3faec237faa6612 (diff)
queue dependancies
-rw-r--r--ANNOUCE.1.4.038
-rw-r--r--FS/FS.pm4
-rw-r--r--FS/FS/part_export/sqlradius.pm34
-rw-r--r--FS/FS/queue.pm37
-rw-r--r--FS/FS/queue_depend.pm120
-rw-r--r--FS/MANIFEST1
-rw-r--r--FS/bin/freeside-queued12
-rw-r--r--FS/t/queue_depend.t5
-rw-r--r--Makefile2
-rw-r--r--README.1.4.0pre1327
-rwxr-xr-xbin/fs-setup13
-rw-r--r--eg/export_template.pm11
-rw-r--r--httemplate/docs/install.html2
-rw-r--r--httemplate/docs/schema.diabin11176 -> 11452 bytes
-rw-r--r--httemplate/docs/schema.html6
-rw-r--r--httemplate/docs/schema.pngbin446146 -> 496268 bytes
-rw-r--r--httemplate/docs/upgrade8.html8
17 files changed, 268 insertions, 52 deletions
diff --git a/ANNOUCE.1.4.0 b/ANNOUCE.1.4.0
index 63fd3fa..a3d7865 100644
--- a/ANNOUCE.1.4.0
+++ b/ANNOUCE.1.4.0
@@ -107,22 +107,24 @@ and suspension/unsuspension.
--
-added case-insensitive and substring to default search
-
-full history tables (notification for deleted payments)
-
-alternate templates (late invoices!)
-
-new export! (well, almost)
-
-icradius groups (usergroup table if not radgroupreply & radgroupcheck)
-
-message catalogs (infrastructure, anyway) & anything which gets sent to a
-customer from the signup server should use message catalog
-
-multi-agent signup server
-
-signup_server-realtime to run cards immediately
-
-and signup-alternate.html for free/paid packages on same signup
+- New export code!
+- Name and company searches:
+ - now case-insensative
+ - pulldown for search type
+- Email notification for deleted payments
+- History tables - complete history of all database changes
+- Alternate invoice templates for things like late noitces
+- ICRADIUS groups (usergroup table if not radgroupreply & radgroupcheck)
+- Signup server
+ - Error messages in message catalog
+ - Agent is now selectable (multiple signup servers for different agents
+ can now run on the same machine)
+ - signup_server-realtime configuration option to run cards immediately
+ - signup-alternate.html example for free and pay packages on the same
+ signup page
+- Texas tax
+
+schema diagram
+
+--
diff --git a/FS/FS.pm b/FS/FS.pm
index 3a9c9f3..963c735 100644
--- a/FS/FS.pm
+++ b/FS/FS.pm
@@ -31,7 +31,7 @@ L<FS::CGI> - Non OO-subroutines for the web interface.
L<FS::Msgcat> - Message catalog
-L<FS::SearchCache> - Message catalog
+L<FS::SearchCache> - Search cache
L<FS::raddb> - RADIUS dictionary
@@ -134,6 +134,8 @@ L<FS::queue> - Job queue
L<FS::queue_arg> - Job arguments
+L<FS::queue_depend> - Job dependencies
+
L<FS::msgcat> - Message catalogs
=head1 Remote API modules
diff --git a/FS/FS/part_export/sqlradius.pm b/FS/FS/part_export/sqlradius.pm
index fc680d4..51a8280 100644
--- a/FS/FS/part_export/sqlradius.pm
+++ b/FS/FS/part_export/sqlradius.pm
@@ -14,15 +14,16 @@ sub _export_insert {
my $method = "radius_$table";
my %attrib = $svc_acct->$method;
next unless keys %attrib;
- my $error = $self->sqlradius_queue( $svc_acct->svcnum, 'insert',
+ my $err_or_queue = $self->sqlradius_queue( $svc_acct->svcnum, 'insert',
$table, $svc_acct->username, %attrib );
- return $error if $error;
+ return $err_or_queue unless ref($err_or_queue);
}
my @groups = $svc_acct->radius_groups;
if ( @groups ) {
- my $error = $self->sqlradius_queue( $svc_acct->svcnum, 'usergroup_insert',
+ my $err_or_queue = $self->sqlradius_queue(
+ $svc_acct->svcnum, 'usergroup_insert',
$svc_acct->username, @groups );
- return $error if $error;
+ return $err_or_queue unless ref($err_or_queue);
}
'';
}
@@ -33,9 +34,9 @@ sub _export_replace {
#return "can't (yet) change username with sqlradius"
# if $old->username ne $new->username;
if ( $old->username ne $new->username ) {
- my $error = $self->sqlradius_queue( $new->svcnum, 'rename',
+ my $err_or_queue = $self->sqlradius_queue( $new->svcnum, 'rename',
$new->username, $old->username );
- return $error if $error;
+ return $err_or_queue unless ref($err_or_queue);
}
foreach my $table (qw(reply check)) {
@@ -46,16 +47,16 @@ sub _export_replace {
|| $new{$_} ne $old{$_} #changed
} keys %new
) {
- my $error = $self->sqlradius_queue( $new->svcnum, 'insert',
+ my $err_or_queue = $self->sqlradius_queue( $new->svcnum, 'insert',
$table, $new->username, %new );
- return $error if $error;
+ return $err_or_queue unless ref($err_or_queue);
}
my @del = grep { !exists $new{$_} } keys %old;
if ( @del ) {
- my $error = $self->sqlradius_queue( $new->svcnum, 'attrib_delete',
+ my $err_or_queue = $self->sqlradius_queue( $new->svcnum, 'attrib_delete',
$table, $new->username, @del );
- return $error if $error;
+ return $err_or_queue unless ref($err_or_queue);
}
}
@@ -72,15 +73,15 @@ sub _export_replace {
}
if ( @delgroups ) {
- my $error = $self->sqlradius_queue( $new->svcnum, 'usergroup_delete',
+ my $err_or_queue = $self->sqlradius_queue( $new->svcnum, 'usergroup_delete',
$new->username, @delgroups );
- return $error if $error;
+ return $err_or_queue unless ref($err_or_queue);
}
if ( @newgroups ) {
- my $error = $self->sqlradius_queue( $new->svcnum, 'usergroup_insert',
+ my $err_or_queue = $self->sqlradius_queue( $new->svcnum, 'usergroup_insert',
$new->username, @newgroups );
- return $error if $error;
+ return $err_or_queue unless ref($err_or_queue);
}
'';
@@ -88,8 +89,9 @@ sub _export_replace {
sub _export_delete {
my( $self, $svc_acct ) = (shift, shift);
- $self->sqlradius_queue( $svc_acct->svcnum, 'delete',
+ my $err_or_queue = $self->sqlradius_queue( $svc_acct->svcnum, 'delete',
$svc_acct->username );
+ ref($err_or_queue) ? '' : $err_or_queue;
}
sub sqlradius_queue {
@@ -103,7 +105,7 @@ sub sqlradius_queue {
$self->option('username'),
$self->option('password'),
@_,
- );
+ ) or $queue;
}
sub sqlradius_insert { #subroutine, not method
diff --git a/FS/FS/queue.pm b/FS/FS/queue.pm
index 5719eff..c75f758 100644
--- a/FS/FS/queue.pm
+++ b/FS/FS/queue.pm
@@ -8,6 +8,7 @@ use FS::Conf;
use FS::Record qw( qsearch qsearchs dbh );
#use FS::queue;
use FS::queue_arg;
+use FS::queue_depend;
use FS::cust_svc;
@ISA = qw(FS::Record);
@@ -144,7 +145,8 @@ sub delete {
local $FS::UID::AutoCommit = 0;
my $dbh = dbh;
- my @args = qsearch( 'queue_arg', { 'jobnum' => $self->jobnum } );
+ my @del = qsearch( 'queue_arg', { 'jobnum' => $self->jobnum } );
+ push @del, qsearch( 'queue_depend', { 'depend_jobnum' => $self->jobnum } );
my $error = $self->SUPER::delete;
if ( $error ) {
@@ -152,8 +154,8 @@ sub delete {
return $error;
}
- foreach my $arg ( @args ) {
- $error = $arg->delete;
+ foreach my $del ( @del ) {
+ $error = $del->delete;
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
return $error;
@@ -206,6 +208,8 @@ sub check {
=item args
+Returns a list of the arguments associated with this job.
+
=cut
sub args {
@@ -228,6 +232,31 @@ sub cust_svc {
qsearchs('cust_svc', { 'svcnum' => $self->svcnum } );
}
+=item depend_insert OTHER_JOBNUM
+
+Inserts a dependancy for this job. If there is an error, returns the error,
+otherwise returns false.
+
+When using job dependancies, you should wrap the insertion of jobs in a
+database transaction.
+
+=cut
+
+sub depend_insert {
+ my($self, $other_jobnum) = @_;
+ my $queue_depend = new FS::queue_depend (
+ 'jobnum' => $self->jobnum,
+ 'depend_jobnum' => $other_jobnum,
+ );
+ $queue_depend->insert;
+}
+
+=back
+
+=head1 SUBROUTINES
+
+=over 4
+
=item joblisting HASHREF NOACTIONS
=cut
@@ -331,7 +360,7 @@ END
=head1 VERSION
-$Id: queue.pm,v 1.11 2002-04-13 08:51:54 ivan Exp $
+$Id: queue.pm,v 1.12 2002-05-15 13:24:24 ivan Exp $
=head1 BUGS
diff --git a/FS/FS/queue_depend.pm b/FS/FS/queue_depend.pm
new file mode 100644
index 0000000..4a4e3c5
--- /dev/null
+++ b/FS/FS/queue_depend.pm
@@ -0,0 +1,120 @@
+package FS::queue_depend;
+
+use strict;
+use vars qw( @ISA );
+use FS::Record qw( qsearch qsearchs );
+use FS::queue;
+
+@ISA = qw(FS::Record);
+
+=head1 NAME
+
+FS::queue_depend - Object methods for queue_depend records
+
+=head1 SYNOPSIS
+
+ use FS::queue_depend;
+
+ $record = new FS::queue_depend \%hash;
+ $record = new FS::queue_depend { 'column' => 'value' };
+
+ $error = $record->insert;
+
+ $error = $new_record->replace($old_record);
+
+ $error = $record->delete;
+
+ $error = $record->check;
+
+=head1 DESCRIPTION
+
+An FS::queue_depend object represents an job dependancy. FS::queue_depend
+inherits from FS::Record. The following fields are currently supported:
+
+=over 4
+
+=item dependnum - primary key
+
+=item jobnum - source jobnum (see L<FS::queue>).
+
+=item depend_jobnum - dependancy jobnum (see L<FS::queue>)
+
+=back
+
+The job specified by B<jobnum> depends on the job specified B<depend_jobnum> -
+the B<jobnum> job will not be run until the B<depend_jobnum> job has completed
+sucessfully (or manually removed).
+
+=head1 METHODS
+
+=over 4
+
+=item new HASHREF
+
+Creates a new dependancy. To add the dependancy to the database, see
+L<"insert">.
+
+Note that this stores the hash reference, not a distinct copy of the hash it
+points to. You can ask the object for a copy with the I<hash> method.
+
+=cut
+
+# the new method can be inherited from FS::Record, if a table method is defined
+
+sub table { 'queue_depend'; }
+
+=item insert
+
+Adds this record to the database. If there is an error, returns the error,
+otherwise returns false.
+
+=cut
+
+# the insert method can be inherited from FS::Record
+
+=item delete
+
+Delete this record from the database.
+
+=cut
+
+# the delete method can be inherited from FS::Record
+
+=item replace OLD_RECORD
+
+Replaces the OLD_RECORD with this one in the database. If there is an error,
+returns the error, otherwise returns false.
+
+=cut
+
+# the replace method can be inherited from FS::Record
+
+=item check
+
+Checks all fields to make sure this is a valid dependancy. If there is
+an error, returns the error, otherwise returns false. Called by the insert
+and replace methods.
+
+=cut
+
+sub check {
+ my $self = shift;
+
+ $self->ut_numbern('dependnum')
+ || $self->ut_foreign_key('jobnum', 'queue', 'jobnum')
+ || $self->ut_foreign_key('depend_jobnum', 'queue', 'jobnum')
+ ;
+}
+
+=back
+
+=head1 BUGS
+
+=head1 SEE ALSO
+
+L<FS::queue>, L<FS::Record>, schema.html from the base documentation.
+
+=cut
+
+1;
+
diff --git a/FS/MANIFEST b/FS/MANIFEST
index 2e72d5a..a95470b 100644
--- a/FS/MANIFEST
+++ b/FS/MANIFEST
@@ -78,6 +78,7 @@ FS/raddb.pm
FS/radius_usergroup.pm
FS/queue.pm
FS/queue_arg.pm
+FS/queue_depend.pm
FS/msgcat.pm
FS/cust_tax_exempt.pm
t/agent.t
diff --git a/FS/bin/freeside-queued b/FS/bin/freeside-queued
index 49b532e..1539a48 100644
--- a/FS/bin/freeside-queued
+++ b/FS/bin/freeside-queued
@@ -59,13 +59,16 @@ while (1) {
}
$warnkids=0;
+ my $nodepend = 'AND 0 = ( SELECT COUNT(*) FROM queue_depend'.
+ ' WHERE queue_depend.jobnum = queue.jobnum ) ';
+
my $job = qsearchs(
'queue',
{ 'status' => 'new' },
'',
driver_name =~ /^mysql$/i
- ? 'ORDER BY jobnum LIMIT 1 FOR UPDATE'
- : 'ORDER BY jobnum FOR UPDATE LIMIT 1'
+ ? "$nodepend ORDER BY jobnum LIMIT 1 FOR UPDATE"
+ : "$nodepend ORDER BY jobnum FOR UPDATE LIMIT 1"
) or do {
sleep 5; #connecting to db is expensive
next;
@@ -94,10 +97,9 @@ while (1) {
$kids++;
} else { #kid time
- #get new db handles
+ #get new db handle
$FS::UID::dbh->{InactiveDestroy} = 1;
- $FS::svc_acct::icradius_dbh->{InactiveDestroy} = 1
- if $FS::svc_acct::icradius_dbh;
+
forksuidsetup($user);
#auto-use export classes...
diff --git a/FS/t/queue_depend.t b/FS/t/queue_depend.t
new file mode 100644
index 0000000..8eaa2cd
--- /dev/null
+++ b/FS/t/queue_depend.t
@@ -0,0 +1,5 @@
+BEGIN { $| = 1; print "1..1\n" }
+END {print "not ok 1\n" unless $loaded;}
+use FS::queue_depend;
+$loaded=1;
+print "ok 1\n";
diff --git a/Makefile b/Makefile
index 68ef794..be4e9db 100644
--- a/Makefile
+++ b/Makefile
@@ -25,8 +25,6 @@ INSTALLGROUP = root
#not changable yet
FREESIDE_CONF = /usr/local/etc/freeside
-#VERSION=1.4.0pre12
-#TAG=freeside_1_4_0_pre12
VERSION=1.4.0pre13
TAG=freeside_1_4_0_pre13
#VERSION=1.4.0beta1
diff --git a/README.1.4.0pre13 b/README.1.4.0pre13
new file mode 100644
index 0000000..bd9fb73
--- /dev/null
+++ b/README.1.4.0pre13
@@ -0,0 +1,27 @@
+the following is necessary to upgrade from 1.4.0pre12 to 1.4.0pre13
+
+if you're upgrading from before 1.4.0pre13 see README.1.4.0pre12 first!
+
+if you're upgrading from 1.3.1 follow the instructions in
+httemplate/docs/upgrade8.html instead
+
+----
+
+install the FS perl modules and httemplate as per install.html or upgrade8.html
+
+CREATE TABLE queue_depend (
+ dependnum int primary key,
+ jobnum int not null,
+ depend_jobnum int not null
+);
+CREATE INDEX queue_depend1 ON queue_depend ( jobnum );
+CREATE INDEX queue_depend2 ON queue_depend ( depend_jobnum );
+
+Run bin/dbdef-create
+
+Run bin/create-history-tables [username] queue_depend
+
+Run bin/dbdef-create again
+
+Restart Apache and freeside-queued
+
diff --git a/bin/fs-setup b/bin/fs-setup
index e05d445..87921d7 100755
--- a/bin/fs-setup
+++ b/bin/fs-setup
@@ -1,6 +1,6 @@
#!/usr/bin/perl -Tw
#
-# $Id: fs-setup,v 1.90 2002-05-04 15:00:18 ivan Exp $
+# $Id: fs-setup,v 1.91 2002-05-15 13:24:24 ivan Exp $
#to delay loading dbdef until we're ready
BEGIN { $FS::Record::setup_hack = 1; }
@@ -933,6 +933,17 @@ sub tables_hash_hack {
'index' => [ [ 'jobnum' ] ],
},
+ 'queue_depend' => {
+ 'columns' => [
+ 'dependnum', 'int', '', '',
+ 'jobnum', 'int', '', '',
+ 'depend_jobnum', 'int', '', '',
+ ],
+ 'primary_key' => 'dependnum',
+ 'unique' => [],
+ 'index' => [ [ 'jobnum' ], [ 'depend_jobnum' ] ],
+ },
+
'export_svc' => {
'columns' => [
'exportsvcnum' => 'int', '', '',
diff --git a/eg/export_template.pm b/eg/export_template.pm
index f2a5a19..1d441bd 100644
--- a/eg/export_template.pm
+++ b/eg/export_template.pm
@@ -9,8 +9,9 @@ sub rebless { shift; }
sub _export_insert {
my($self, $svc_something) = (shift, shift);
- $self->myexport_queue( $svc_acct->svcnum, 'insert',
+ $err_or_queue = $self->myexport_queue( $svc_acct->svcnum, 'insert',
$svc_something->username, $svc_something->_password );
+ ref($err_or_queue) ? '' : $err_or_queue;
}
sub _export_replace {
@@ -18,14 +19,16 @@ sub _export_replace {
#return "can't change username with myexport"
# if $old->username ne $new->username;
#return '' unless $old->_password ne $new->_password;
- $self->myexport_queue( $new->svcnum,
+ $err_or_queue = $self->myexport_queue( $new->svcnum,
'replace', $new->username, $new->_password );
+ ref($err_or_queue) ? '' : $err_or_queue;
}
sub _export_delete {
my( $self, $svc_something ) = (shift, shift);
- $self->myexport_queue( $svc_acct->svcnum,
+ $err_or_queue = $self->myexport_queue( $svc_acct->svcnum,
'delete', $svc_something->username );
+ ref($err_or_queue) ? '' : $err_or_queue;
}
#a good idea to queue anything that could fail or take any time
@@ -35,7 +38,7 @@ sub myexport_queue {
'svcnum' => $svcnum,
'job' => "FS::part_export::myexport::myexport_$method",
};
- $queue->insert( @_ );
+ $queue->insert( @_ ) or $queue;
}
sub myexport_insert { #subroutine, not method
diff --git a/httemplate/docs/install.html b/httemplate/docs/install.html
index 5c13ac1..26fa34d 100644
--- a/httemplate/docs/install.html
+++ b/httemplate/docs/install.html
@@ -186,7 +186,7 @@ $ bin/fs-setup <b>username</b>
$ su freeside
$ bin/populate-msgcat <b>username</b>
</pre>
- <li><tt>freeside-queued</tt> was installed with the Perl modules. Start it now and ensure that is run upon system startup.
+ <li><tt>freeside-queued</tt> was installed with the Perl modules. Start it now and ensure that is run upon system startup (Do this manually, or, edit the top-level Makefile, replacing INIT_FILE with the appropriate location on your system, and run <tt>make install-init</tt>.
<li>Now proceed to the initial <a href="admin.html">administration</a> of your installation.
</ul>
</body>
diff --git a/httemplate/docs/schema.dia b/httemplate/docs/schema.dia
index 148c1df..c22a470 100644
--- a/httemplate/docs/schema.dia
+++ b/httemplate/docs/schema.dia
Binary files differ
diff --git a/httemplate/docs/schema.html b/httemplate/docs/schema.html
index 3f62744..2b8b3a1 100644
--- a/httemplate/docs/schema.html
+++ b/httemplate/docs/schema.html
@@ -401,6 +401,12 @@
<li>jobnum - <a href="#queue">job</a>
<li>arg - argument
</ul>
+ <li><a name="queue_depend" href="man/FS/queue_depend.html">queue_depend</a> - job dependancies
+ <ul>
+ <li>dependnum - primary key
+ <li>jobnum - source jobnum
+ <li>depend_jobnum - dependancy jobnum
+ </ul>
<li><a name="radius_usergroup" href="man/FS/radius_usergroup.html">radius_usergroup</a> - Link users to RADIUS groups.
<ul>
<li>usergroupnum - primary key
diff --git a/httemplate/docs/schema.png b/httemplate/docs/schema.png
index b3f0037..ba22f59 100644
--- a/httemplate/docs/schema.png
+++ b/httemplate/docs/schema.png
Binary files differ
diff --git a/httemplate/docs/upgrade8.html b/httemplate/docs/upgrade8.html
index 97758fd..e6184df 100644
--- a/httemplate/docs/upgrade8.html
+++ b/httemplate/docs/upgrade8.html
@@ -120,6 +120,14 @@ CREATE TABLE queue_arg (
);
CREATE INDEX queue_arg1 ON queue_arg ( jobnum );
+CREATE TABLE queue_depend (
+ dependnum int primary key,
+ jobnum int not null,
+ depend_jobnum int not null
+);
+CREATE INDEX queue_depend1 ON queue_depend ( jobnum );
+CREATE INDEX queue_depend2 ON queue_depend ( depend_jobnum );
+
CREATE TABLE part_pop_local (
localnum int primary key,
popnum int not null,