fossology icon indicating copy to clipboard operation
fossology copied to clipboard

feat(API): `/jobs/history?upload={id}` GET route to get the history of all the jobs queued based on an upload

Open krishna9304 opened this issue 2 years ago • 1 comments

Signed-off-by: Krishna Mahato [email protected]

Description

This development of this PR is in reference to two tasks ---

  • [x] Fixing the bug that caused GET uploads/{id}/summary to give a 500 response when requesting the summary of an upload which was a file.
  • [x] Exposing GET /jobs/history?upload={id} route to get the history of all the jobs queued based on an upload.
    • P.S.: Here {id} is the upload id.

How to test

  • Use any API platform like postman.
  • Pull the changes from this PR.

Testing GET /jobs/history?upload={id}

You can expect a response like this ----

[
    {
        "jobId": 8,
        "jobName": "hotels.json",
        "jobQueue": [
            {
                "jobQueueId": 16,
                "jobQueueType": "ununpack",
                "startTime": "2022-08-22 14:17:48",
                "endTime": "2022-08-22 14:17:48",
                "status": "Completed",
                "itemsProcessed": 1,
                "dependencies": [
                    null
                ],
                "itemsPerSec": 1,
                "canDoActions": true,
                "isInProgress": false,
                "isReady": true,
                "download": ""
            },
            {
                "jobQueueId": 17,
                "jobQueueType": "adj2nest",
                "startTime": "2022-08-22 14:17:49",
                "endTime": "2022-08-22 14:17:49",
                "status": "Completed",
                "itemsProcessed": 1,
                "dependencies": [
                    "16"
                ],
                "itemsPerSec": 1,
                "canDoActions": true,
                "isInProgress": false,
                "isReady": true,
                "download": ""
            },
            {
                "jobQueueId": 18,
                "jobQueueType": "monk",
                "startTime": "2022-08-22 14:17:50",
                "endTime": "2022-08-22 14:17:51",
                "status": "Completed",
                "itemsProcessed": 1,
                "dependencies": [
                    "17"
                ],
                "itemsPerSec": 1,
                "canDoActions": true,
                "isInProgress": false,
                "isReady": true,
                "download": ""
            },
            {
                "jobQueueId": 19,
                "jobQueueType": "nomos",
                "startTime": "2022-08-22 14:17:50",
                "endTime": "2022-08-22 14:17:51",
                "status": "Completed",
                "itemsProcessed": 1,
                "dependencies": [
                    "17"
                ],
                "itemsPerSec": 1,
                "canDoActions": true,
                "isInProgress": false,
                "isReady": true,
                "download": ""
            },
            {
                "jobQueueId": 20,
                "jobQueueType": "ojo",
                "startTime": "2022-08-22 14:17:50",
                "endTime": "2022-08-22 14:17:50",
                "status": "Completed",
                "itemsProcessed": 1,
                "dependencies": [
                    "17"
                ],
                "itemsPerSec": 1,
                "canDoActions": true,
                "isInProgress": false,
                "isReady": true,
                "download": ""
            }
        ],
        "upload": {
            "uploadName": "hotels.json",
            "uploadId": "4",
            "uploadDesc": "",
            "uploadItem": "91",
            "uploadEta": ""
        }
    },
    {
        "jobId": 9,
        "jobName": "hotels.json",
        "jobQueue": [
            {
                "jobQueueId": 21,
                "jobQueueType": "clixml",
                "startTime": "2022-09-01 17:08:52",
                "endTime": "2022-09-01 17:08:52",
                "status": "Failed",
                "itemsProcessed": 0,
                "dependencies": [
                    null
                ],
                "itemsPerSec": 0,
                "canDoActions": true,
                "isInProgress": false,
                "isReady": false,
                "download": "Clixml Report"
            }
        ],
        "upload": {
            "uploadName": "hotels.json",
            "uploadId": "4",
            "uploadDesc": "",
            "uploadItem": "91",
            "uploadEta": ""
        }
    },
    {
        "jobId": 37,
        "jobName": "hotels.json",
        "jobQueue": [
            {
                "jobQueueId": 49,
                "jobQueueType": "reportImport",
                "startTime": null,
                "endTime": "2022-09-03 19:28:19",
                "status": "killed by fossy",
                "itemsProcessed": 0,
                "dependencies": [
                    null
                ],
                "itemsPerSec": 0,
                "canDoActions": true,
                "isInProgress": false,
                "isReady": false,
                "download": "uploaded SPDX2 report"
            }
        ],
        "upload": {
            "uploadName": "hotels.json",
            "uploadId": "4",
            "uploadDesc": "",
            "uploadItem": "91",
            "uploadEta": ""
        }
    },
    {
        "jobId": 45,
        "jobName": "hotels.json",
        "jobQueue": [
            {
                "jobQueueId": 57,
                "jobQueueType": "reportImport",
                "startTime": "2022-09-03 21:45:19",
                "endTime": "2022-09-03 21:45:19",
                "status": "Failed",
                "itemsProcessed": 0,
                "dependencies": [
                    null
                ],
                "itemsPerSec": 0,
                "canDoActions": true,
                "isInProgress": false,
                "isReady": false,
                "download": "uploaded SPDX2 report"
            }
        ],
        "upload": {
            "uploadName": "hotels.json",
            "uploadId": "4",
            "uploadDesc": "",
            "uploadItem": "91",
            "uploadEta": ""
        }
    }
]

This fixes #2306 . @GMishx @shaheemazmalmmd @Shruti3004 PTAL.

krishna9304 avatar Sep 01 '22 07:09 krishna9304

This pull request has conflicts, please rebase with master to resolve those before we can evaluate the pull request.

github-actions[bot] avatar Sep 03 '22 04:09 github-actions[bot]