FOSSology  4.4.0
Open Source License Compliance by Open Source Software
AjaxJobStatus.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2015 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
8 namespace Fossology\UI\Ajax;
9 
13 use Symfony\Component\HttpFoundation\Request;
14 use Symfony\Component\HttpFoundation\JsonResponse;
15 
17 {
18  const NAME = "jobstatus";
20  private $dbManager;
21 
22  function __construct()
23  {
24  parent::__construct(self::NAME, array(
25  self::PERMISSION => Auth::PERM_READ
26  ));
27  $this->dbManager = $this->getObject('db.manager');
28  }
29 
35  protected function handle(Request $request)
36  {
37  $response = '1';
38  $jobInfo = $this->dbManager->getSingleRow(
39  "SELECT jq_end_bits FROM jobqueue WHERE jq_end_bits = '0' LIMIT 1;");
40  if (empty($jobInfo)) {
41  $response = '0';
42  }
43  $status = 1;
45  $status = empty($status) ? JsonResponse::HTTP_INTERNAL_SERVER_ERROR : JsonResponse::HTTP_OK;
46  return new JsonResponse(array("status" => $response), $status);
47  }
48 }
49 
50 register_plugin(new AjaxJobStatus());
Contains the constants and helpers for authentication of user.
Definition: Auth.php:24
handle(Request $request)
: returns 1 when jobs are running else 0
ReportCachePurgeAll()
Purge all records from the report cache.
fo_dbManager * dbManager
fo_dbManager object
Definition: process.c:16