@@ -1492,13 +1492,7 @@ class ProductTabActivityView(
14921492 def get_context_data (self , ** kwargs ):
14931493 context_data = super ().get_context_data (** kwargs )
14941494 scancode_projects = self .object .scancodeprojects .all ()
1495- submitted_projects = self .get_submitted_projects (scancode_projects )
1496-
1497- # Check the status of the "submitted" projects on ScanCode.io and update the
1498- # local ScanCodeProject instances accordingly.
1499- scancodeio = ScanCodeIO (self .request .user .dataspace )
1500- for submitted_project in submitted_projects :
1501- self .synchronize (scancodeio = scancodeio , project = submitted_project )
1495+ self .synchronize_scancodeio_projects (scancode_projects )
15021496
15031497 history_entries = (
15041498 History .objects .get_for_object (self .object )
@@ -1509,9 +1503,9 @@ def get_context_data(self, **kwargs):
15091503 context_data .update (
15101504 {
15111505 "tab_view_url" : self .object .get_url ("tab_activity" ),
1512- # Imports
1506+ # Actions
15131507 "scancode_projects" : scancode_projects ,
1514- "has_projects_in_progress" : bool ( submitted_projects ),
1508+ "has_projects_in_progress" : scancode_projects . in_progress (). exists ( ),
15151509 # Requests
15161510 "requests" : self .object .get_requests (self .request .user ),
15171511 # History
@@ -1521,20 +1515,32 @@ def get_context_data(self, **kwargs):
15211515
15221516 return context_data
15231517
1524- @staticmethod
1525- def get_submitted_projects (scancode_projects ):
1526- submitted_types = [
1518+ def synchronize_scancodeio_projects (self , scancode_projects ):
1519+ """
1520+ Poll ScanCode.io for the run status of the projects submitted to it as
1521+ external pipeline runs (SBOM and manifest imports), and update the
1522+ local ScanCodeProject status accordingly.
1523+ Other action types are handled entirely by local RQ tasks and have no
1524+ external run to poll.
1525+ """
1526+ scancodeio_project_types = [
15271527 ScanCodeProject .ProjectType .LOAD_SBOMS ,
15281528 ScanCodeProject .ProjectType .IMPORT_FROM_MANIFEST ,
15291529 ]
1530- return [
1530+ pending_scancodeio_projects = [
15311531 project
15321532 for project in scancode_projects
15331533 if project .status == ScanCodeProject .Status .SUBMITTED
1534- and project .type in submitted_types
1534+ and project .type in scancodeio_project_types
15351535 ]
1536+ if not pending_scancodeio_projects :
1537+ return
1538+
1539+ scancodeio = ScanCodeIO (self .request .user .dataspace )
1540+ for project in pending_scancodeio_projects :
1541+ self .synchronize_scancodeio_project_status (scancodeio , project )
15361542
1537- def synchronize (self , scancodeio , project ):
1543+ def synchronize_scancodeio_project_status (self , scancodeio , project ):
15381544 scan_detail_url = scancodeio .get_scan_detail_url (project .project_uuid )
15391545 scan_data = scancodeio .fetch_scan_data (scan_detail_url )
15401546 if not scan_data :
@@ -2899,7 +2905,7 @@ def improve_packages_from_purldb_view(request, dataspace, name, version=""):
28992905 messages .error (request , "Improve Packages already in progress..." )
29002906 else :
29012907 transaction .on_commit (
2902- lambda : improve_packages_from_purldb_task (
2908+ lambda : improve_packages_from_purldb_task . delay (
29032909 product_uuid = product .uuid ,
29042910 user_uuid = user .uuid ,
29052911 )
0 commit comments