summaryrefslogtreecommitdiff
path: root/lorry-controller-webapp
diff options
context:
space:
mode:
Diffstat (limited to 'lorry-controller-webapp')
-rwxr-xr-xlorry-controller-webapp21
1 files changed, 21 insertions, 0 deletions
diff --git a/lorry-controller-webapp b/lorry-controller-webapp
index 0ff9d65..e70b132 100755
--- a/lorry-controller-webapp
+++ b/lorry-controller-webapp
@@ -288,6 +288,13 @@ class StateDB(object):
raise WrongNumberLorriesRunningJob(job_id, len(rows))
return rows[0][0]
+ def get_running_jobs(self):
+ logging.debug('StateDB.get_running_jobs() called')
+ c = self.get_cursor()
+ c.execute(
+ 'SELECT running_job FROM lorries WHERE running_job IS NOT NULL')
+ return [row[0] for row in c.fetchall()]
+
class LorryControllerRoute(object):
@@ -597,6 +604,20 @@ class JobUpdate(LorryControllerRoute):
self.statedb.set_running_job(path, None)
+class ListRunningJobs(LorryControllerRoute):
+
+ http_method = 'GET'
+ path = '/1.0/list-running-jobs'
+
+ def run(self, **kwargs):
+ logging.debug('%s %s called', self.http_method, self.path)
+
+ job_ids = self.statedb.get_running_jobs()
+ return {
+ 'running_jobs': job_ids,
+ }
+
+
class WEBAPP(cliapp.Application):
def add_settings(self):