mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-14 07:04:27 -04:00
refactor: Remove unneeded prefetch related
This commit is contained in:
parent
c565fad75c
commit
0f13087a09
2 changed files with 2 additions and 4 deletions
|
@ -1,12 +1,11 @@
|
||||||
from django.utils.html import format_html
|
from django.utils.html import format_html
|
||||||
|
|
||||||
from core.models import Snapshot, EXTRACTORS
|
from core.models import Snapshot, EXTRACTORS
|
||||||
from core.settings import DEBUG
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
def get_icons(snapshot: Snapshot) -> str:
|
def get_icons(snapshot: Snapshot) -> str:
|
||||||
archive_results = list(snapshot.archiveresult_set.all())
|
archive_results = snapshot.archiveresult_set.filter(status="succeeded")
|
||||||
link = snapshot.as_link()
|
link = snapshot.as_link()
|
||||||
canon = link.canonical_outputs()
|
canon = link.canonical_outputs()
|
||||||
output = ""
|
output = ""
|
||||||
|
@ -29,7 +28,7 @@ def get_icons(snapshot: Snapshot) -> str:
|
||||||
|
|
||||||
for extractor, _ in EXTRACTORS:
|
for extractor, _ in EXTRACTORS:
|
||||||
for result in archive_results:
|
for result in archive_results:
|
||||||
if result.extractor != extractor or result.status != "succeeded":
|
if result.extractor != extractor:
|
||||||
continue
|
continue
|
||||||
path = link.archive_path
|
path = link.archive_path
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -98,7 +98,6 @@ class PublicArchiveView(ListView):
|
||||||
query = self.request.GET.get('q')
|
query = self.request.GET.get('q')
|
||||||
if query:
|
if query:
|
||||||
qs = Snapshot.objects.filter(title__icontains=query)
|
qs = Snapshot.objects.filter(title__icontains=query)
|
||||||
qs = qs.prefetch_related("archiveresult_set").all()
|
|
||||||
for snapshot in qs:
|
for snapshot in qs:
|
||||||
snapshot.icons = get_icons(snapshot)
|
snapshot.icons = get_icons(snapshot)
|
||||||
return qs
|
return qs
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue