summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Cron/bill.pm4
-rw-r--r--FS/FS/Schema.pm2
-rw-r--r--FS/bin/freeside-queued21
3 files changed, 17 insertions, 10 deletions
diff --git a/FS/FS/Cron/bill.pm b/FS/FS/Cron/bill.pm
index 8c0f8351c..ecc891003 100644
--- a/FS/FS/Cron/bill.pm
+++ b/FS/FS/Cron/bill.pm
@@ -124,8 +124,8 @@ END
#add job to queue that calls bill_and_collect with options
my $queue = new FS::queue {
- 'job' => 'FS::cust_main::queued_bill',
- 'secure' => 'Y',
+ 'job' => 'FS::cust_main::queued_bill',
+ 'priority' => 99, #don't get in the way of provisioning jobs
};
my $error = $queue->insert( 'custnum'=>$custnum, %args );
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 1ab37af45..f1692b552 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -1184,6 +1184,8 @@ sub tables_hashref {
'status', 'varchar', '', $char_d, '', '',
'statustext', 'text', 'NULL', '', '', '',
'svcnum', 'int', 'NULL', '', '', '',
+ 'custnum', 'int', 'NULL', '', '', '',
+ 'priority', 'int', 'NULL', '', '', '',
],
'primary_key' => 'jobnum',
'unique' => [],
diff --git a/FS/bin/freeside-queued b/FS/bin/freeside-queued
index 93d735d1a..4093e5aa8 100644
--- a/FS/bin/freeside-queued
+++ b/FS/bin/freeside-queued
@@ -89,14 +89,19 @@ while (1) {
my $nodepend = 'AND 0 = ( SELECT COUNT(*) FROM queue_depend'.
' WHERE queue_depend.jobnum = queue.jobnum ) ';
- my $job = qsearchs(
- 'queue',
- { 'status' => 'new' },
- '',
- driver_name eq 'mysql'
- ? "$nodepend ORDER BY jobnum LIMIT 1 FOR UPDATE"
- : "$nodepend ORDER BY jobnum FOR UPDATE LIMIT 1"
- ) or do {
+ #anything with a priority goes after stuff without one
+ my $order_by = ' ORDER BY COALESCE(priority,0) ASC, jobnum ASC ';
+
+ $order_by .= ( driver_name eq 'mysql'
+ ? ' LIMIT 1 FOR UPDATE '
+ : ' FOR UPDATE LIMIT 1 ' );
+
+ my $job = qsearchs({
+ 'table' => 'queue',
+ 'hashref' => { 'status' => 'new' },
+ 'extra_sql' => $nodepend,
+ 'order_by' => $order_by,
+ }) or do {
# if $oldAutoCommit {
dbh->commit or do {
warn "WARNING: database error, closing connection: ". dbh->errstr;