From eb6f250b31fa8aa65ec7e8b58dd5247009bf381c Mon Sep 17 00:00:00 2001 From: Jono Yang Date: Fri, 4 Aug 2023 12:17:52 -0700 Subject: [PATCH 1/2] Increase priority on rescanned packages Signed-off-by: Jono Yang --- minecode/management/commands/process_scans.py | 1 + minecode/models.py | 1 + 2 files changed, 2 insertions(+) diff --git a/minecode/management/commands/process_scans.py b/minecode/management/commands/process_scans.py index 11d07168..8023dc63 100644 --- a/minecode/management/commands/process_scans.py +++ b/minecode/management/commands/process_scans.py @@ -145,6 +145,7 @@ def process_scan(cls, scannable_uri, get_scan_info_save_loc='', get_scan_data_sa scannable_uri.scan_status = ScannableURI.SCAN_INDEXED if rescan: scannable_uri.rescan = False + scannable_uri.priority = 0 except Exception as e: error_message = str(e) + '\n' diff --git a/minecode/models.py b/minecode/models.py index 7e7dfce6..16c44854 100644 --- a/minecode/models.py +++ b/minecode/models.py @@ -773,6 +773,7 @@ def rescan(self): self.index_error = None self.scan_uuid = None self.scan_request_date = None + self.priority = 100 self.save() From 7c0ce604bd65d138b13b339f0459bfdd2b414b3d Mon Sep 17 00:00:00 2001 From: Jono Yang Date: Mon, 7 Aug 2023 18:34:04 -0700 Subject: [PATCH 2/2] Update tests Signed-off-by: Jono Yang --- packagedb/tests/test_api.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packagedb/tests/test_api.py b/packagedb/tests/test_api.py index 8311e9e4..02ad2eee 100644 --- a/packagedb/tests/test_api.py +++ b/packagedb/tests/test_api.py @@ -520,6 +520,7 @@ def setUp(self): def test_reindex_package(self): self.assertEqual(False, self.scannableuri.rescan_uri) + self.assertEqual(0, self.scannableuri.priority) self.assertEqual(self.scan_uuid, self.scannableuri.scan_uuid) self.assertEqual('error', self.scannableuri.scan_error) self.assertEqual('error', self.scannableuri.index_error) @@ -528,6 +529,7 @@ def test_reindex_package(self): self.assertEqual('pkg:maven/sample/baz@90.12 has been queued for reindexing', response.data['status']) self.scannableuri.refresh_from_db() self.assertEqual(True, self.scannableuri.rescan_uri) + self.assertEqual(100, self.scannableuri.priority) self.assertEqual(None, self.scannableuri.scan_uuid) self.assertEqual(None, self.scannableuri.scan_error) self.assertEqual(None, self.scannableuri.index_error) @@ -535,12 +537,14 @@ def test_reindex_package(self): def test_reindex_packages_basic(self): self.assertEqual(False, self.scannableuri.rescan_uri) + self.assertEqual(0, self.scannableuri.priority) self.assertEqual(self.scan_uuid, self.scannableuri.scan_uuid) self.assertEqual('error', self.scannableuri.scan_error) self.assertEqual('error', self.scannableuri.index_error) self.assertEqual(self.scan_request_date, self.scannableuri.scan_request_date) self.assertEqual(False, self.scannableuri2.rescan_uri) + self.assertEqual(0, self.scannableuri2.priority) self.assertEqual(self.scan_uuid2, self.scannableuri2.scan_uuid) self.assertEqual('error', self.scannableuri2.scan_error) self.assertEqual('error', self.scannableuri2.index_error) @@ -563,6 +567,7 @@ def test_reindex_packages_basic(self): self.scannableuri.refresh_from_db() self.assertEqual(True, self.scannableuri.rescan_uri) + self.assertEqual(100, self.scannableuri.priority) self.assertEqual(None, self.scannableuri.scan_uuid) self.assertEqual(None, self.scannableuri.scan_error) self.assertEqual(None, self.scannableuri.index_error) @@ -570,6 +575,7 @@ def test_reindex_packages_basic(self): self.scannableuri2.refresh_from_db() self.assertEqual(True, self.scannableuri2.rescan_uri) + self.assertEqual(100, self.scannableuri.priority) self.assertEqual(None, self.scannableuri2.scan_uuid) self.assertEqual(None, self.scannableuri2.scan_error) self.assertEqual(None, self.scannableuri2.index_error)