Переосмыслил отметки по ВЧ загрузке. Улучшил статистику
This commit is contained in:
@@ -43,10 +43,6 @@ class SourceListView(LoginRequiredMixin, View):
|
||||
objitem_count_max = request.GET.get("objitem_count_max", "").strip()
|
||||
date_from = request.GET.get("date_from", "").strip()
|
||||
date_to = request.GET.get("date_to", "").strip()
|
||||
# Signal mark filters
|
||||
has_signal_mark = request.GET.get("has_signal_mark")
|
||||
mark_date_from = request.GET.get("mark_date_from", "").strip()
|
||||
mark_date_to = request.GET.get("mark_date_to", "").strip()
|
||||
|
||||
# Source request filters
|
||||
has_requests = request.GET.get("has_requests")
|
||||
@@ -361,10 +357,6 @@ class SourceListView(LoginRequiredMixin, View):
|
||||
).prefetch_related(
|
||||
# Use Prefetch with filtered queryset
|
||||
Prefetch('source_objitems', queryset=filtered_objitems_qs, to_attr='filtered_objitems'),
|
||||
# Prefetch marks with their relationships
|
||||
'marks',
|
||||
'marks__created_by',
|
||||
'marks__created_by__user'
|
||||
).annotate(
|
||||
# Use annotate for efficient counting in a single query
|
||||
objitem_count=Count('source_objitems', filter=objitem_filter_q, distinct=True) if has_objitem_filter else Count('source_objitems')
|
||||
@@ -403,36 +395,8 @@ class SourceListView(LoginRequiredMixin, View):
|
||||
if selected_ownership:
|
||||
sources = sources.filter(ownership_id__in=selected_ownership)
|
||||
|
||||
# Filter by signal marks
|
||||
if has_signal_mark or mark_date_from or mark_date_to:
|
||||
mark_filter_q = Q()
|
||||
|
||||
# Filter by mark value (signal presence)
|
||||
if has_signal_mark == "1":
|
||||
mark_filter_q &= Q(marks__mark=True)
|
||||
elif has_signal_mark == "0":
|
||||
mark_filter_q &= Q(marks__mark=False)
|
||||
|
||||
# Filter by mark date range
|
||||
if mark_date_from:
|
||||
try:
|
||||
mark_date_from_obj = datetime.strptime(mark_date_from, "%Y-%m-%d")
|
||||
mark_filter_q &= Q(marks__timestamp__gte=mark_date_from_obj)
|
||||
except (ValueError, TypeError):
|
||||
pass
|
||||
|
||||
if mark_date_to:
|
||||
try:
|
||||
from datetime import timedelta
|
||||
mark_date_to_obj = datetime.strptime(mark_date_to, "%Y-%m-%d")
|
||||
# Add one day to include entire end date
|
||||
mark_date_to_obj = mark_date_to_obj + timedelta(days=1)
|
||||
mark_filter_q &= Q(marks__timestamp__lt=mark_date_to_obj)
|
||||
except (ValueError, TypeError):
|
||||
pass
|
||||
|
||||
if mark_filter_q:
|
||||
sources = sources.filter(mark_filter_q).distinct()
|
||||
# NOTE: Фильтры по отметкам сигналов удалены, т.к. ObjectMark теперь связан с TechAnalyze, а не с Source
|
||||
# Для фильтрации по отметкам используйте страницу "Отметки сигналов"
|
||||
|
||||
# Filter by source requests
|
||||
if has_requests == "1":
|
||||
@@ -717,14 +681,8 @@ class SourceListView(LoginRequiredMixin, View):
|
||||
# Get first satellite ID for modal link (if multiple satellites, use first one)
|
||||
first_satellite_id = min(satellite_ids) if satellite_ids else None
|
||||
|
||||
# Get all marks (presence/absence)
|
||||
# Отметки теперь привязаны к TechAnalyze, а не к Source
|
||||
marks_data = []
|
||||
for mark in source.marks.all():
|
||||
marks_data.append({
|
||||
'mark': mark.mark,
|
||||
'timestamp': mark.timestamp,
|
||||
'created_by': str(mark.created_by) if mark.created_by else '-',
|
||||
})
|
||||
|
||||
# Get info name and ownership
|
||||
info_name = source.info.name if source.info else '-'
|
||||
@@ -775,9 +733,6 @@ class SourceListView(LoginRequiredMixin, View):
|
||||
'objitem_count_max': objitem_count_max,
|
||||
'date_from': date_from,
|
||||
'date_to': date_to,
|
||||
'has_signal_mark': has_signal_mark,
|
||||
'mark_date_from': mark_date_from,
|
||||
'mark_date_to': mark_date_to,
|
||||
# Source request filters
|
||||
'has_requests': has_requests,
|
||||
'selected_request_statuses': selected_request_statuses,
|
||||
|
||||
Reference in New Issue
Block a user