@@ -447,7 +447,8 @@ export class SQLiteCompute implements ComputeDatabaseProvider {
447447 environments ?: string [ ] ,
448448 fromTimestamp ?: string ,
449449 consumerAddrs ?: string [ ] ,
450- status ?: C2DStatusNumber
450+ status ?: C2DStatusNumber ,
451+ runningJobs ?: boolean
451452 ) : Promise < DBComputeJob [ ] > {
452453 let selectSQL = `SELECT * FROM ${ this . schema . name } `
453454
@@ -460,9 +461,22 @@ export class SQLiteCompute implements ComputeDatabaseProvider {
460461 params . push ( ...environments )
461462 }
462463
463- if ( fromTimestamp ) {
464- conditions . push ( `dateFinished >= ?` )
465- params . push ( fromTimestamp )
464+ if ( runningJobs ) {
465+ conditions . push ( `status = ?` )
466+ params . push ( C2DStatusNumber . RunningAlgorithm . toString ( ) )
467+ if ( fromTimestamp ) {
468+ conditions . push ( `dateCreated >= ?` )
469+ params . push ( fromTimestamp )
470+ }
471+ } else {
472+ if ( fromTimestamp ) {
473+ conditions . push ( `dateFinished >= ?` )
474+ params . push ( fromTimestamp )
475+ }
476+ if ( status ) {
477+ conditions . push ( `status = ?` )
478+ params . push ( status . toString ( ) )
479+ }
466480 }
467481
468482 if ( consumerAddrs && consumerAddrs . length > 0 ) {
@@ -471,11 +485,6 @@ export class SQLiteCompute implements ComputeDatabaseProvider {
471485 params . push ( ...consumerAddrs )
472486 }
473487
474- if ( status ) {
475- conditions . push ( `status = ?` )
476- params . push ( status . toString ( ) )
477- }
478-
479488 if ( conditions . length > 0 ) {
480489 selectSQL += ` WHERE ${ conditions . join ( ' AND ' ) } `
481490 }
0 commit comments