Skip to content

Commit

Permalink
Merge pull request #161 from nexB/increase-rescan-priority
Browse files Browse the repository at this point in the history
Increase priority on rescanned packages
  • Loading branch information
JonoYang authored Aug 8, 2023
2 parents 5258a92 + 7c0ce60 commit c775297
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions minecode/management/commands/process_scans.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions minecode/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down
6 changes: 6 additions & 0 deletions packagedb/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -528,19 +529,22 @@ 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)
self.assertEqual(None, self.scannableuri.scan_request_date)

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)
Expand All @@ -563,13 +567,15 @@ 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)
self.assertEqual(None, self.scannableuri.scan_request_date)

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)
Expand Down

0 comments on commit c775297

Please sign in to comment.