Skip to content

Commit

Permalink
not using queryset cache when not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
Eldies committed Nov 11, 2024
1 parent d315485 commit 3ca5a3f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cvat/apps/dataset_manager/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,21 @@ def add_prefetch_info(cls, queryset):
)

def __init__(self, pk, *, is_prefetched=False, queryset=None):
is_custom_queryset = queryset is not None
if queryset is None:
queryset = self.add_prefetch_info(models.Job.objects)

if is_prefetched:
self.db_job: models.Job = queryset.select_related(
'segment__task'
).select_for_update().get(id=pk)
else:
elif is_custom_queryset:
self.db_job: models.Job = get_cached(queryset, pk=int(pk))
else:
try:
self.db_job: models.Job = next(queryset.filter(pk=int(pk)).iterator())
except StopIteration:
raise models.Job.DoesNotExist()

db_segment = self.db_job.segment
self.start_frame = db_segment.start_frame
Expand Down

0 comments on commit 3ca5a3f

Please sign in to comment.