Skip to content

Refactor SyncDataSourceJob to change the DataSource status to "queued" when enqueued #18399

@leomarssilva

Description

@leomarssilva

NetBox version

v4.2.1

Feature type

Change to existing functionality

Triage priority

I volunteer to perform this work (if approved)

Proposed functionality

The snippet of code below, used to enqueue DataSource syncing, is duplicated in the following files: netbox/core/api/views.py and netbox/core/views.py

# Enqueue the sync job & update the DataSource's status
job = SyncDataSourceJob.enqueue(instance=datasource, user=request.user)
datasource.status = DataSourceStatusChoices.QUEUED
DataSource.objects.filter(pk=datasource.pk).update(status=datasource.status)

I propose moving the status update code to a new enqueue method on SyncDataSourceJob.

Use case

It removes duplicated code, and the logic can be reused easily for new functionalities (e.g., #18287) or to trigger DataSource syncing from plugins.

Database changes

None.

External dependencies

None.

Metadata

Metadata

Assignees

Labels

status: acceptedThis issue has been accepted for implementationtype: housekeepingChanges to the application which do not directly impact the end user

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions