Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase priority on rescanned packages #161

Merged
merged 2 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading