mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-08 13:39:38 +00:00
fix standard duration str agg
This commit is contained in:
@@ -8,7 +8,7 @@ import urllib.parse
|
|||||||
|
|
||||||
from home.src.download.thumbnails import ThumbManager
|
from home.src.download.thumbnails import ThumbManager
|
||||||
from home.src.ta.config import AppConfig
|
from home.src.ta.config import AppConfig
|
||||||
from home.src.ta.helper import date_praser
|
from home.src.ta.helper import date_praser, get_duration_str
|
||||||
|
|
||||||
|
|
||||||
class SearchProcess:
|
class SearchProcess:
|
||||||
@@ -163,3 +163,15 @@ class SearchProcess:
|
|||||||
subtitle_dict.update({"vid_thumb_url": f"/cache/{thumb_path}"})
|
subtitle_dict.update({"vid_thumb_url": f"/cache/{thumb_path}"})
|
||||||
|
|
||||||
return subtitle_dict
|
return subtitle_dict
|
||||||
|
|
||||||
|
|
||||||
|
def process_aggs(response):
|
||||||
|
"""convert aggs duration to str"""
|
||||||
|
|
||||||
|
if response.get("aggregations"):
|
||||||
|
aggs = response["aggregations"]
|
||||||
|
if "total_duration" in aggs:
|
||||||
|
duration_sec = int(aggs["total_duration"]["value"])
|
||||||
|
aggs["total_duration"].update(
|
||||||
|
{"value_str": get_duration_str(duration_sec)}
|
||||||
|
)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import json
|
|||||||
import urllib.parse
|
import urllib.parse
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
from api.src.search_processor import SearchProcess
|
from api.src.search_processor import SearchProcess, process_aggs
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth import login
|
from django.contrib.auth import login
|
||||||
from django.contrib.auth.forms import AuthenticationForm
|
from django.contrib.auth.forms import AuthenticationForm
|
||||||
@@ -200,6 +200,7 @@ class ArchivistResultsView(ArchivistViewConfig):
|
|||||||
def find_results(self):
|
def find_results(self):
|
||||||
"""add results and pagination to context"""
|
"""add results and pagination to context"""
|
||||||
response, _ = ElasticWrap(self.es_search).get(self.data)
|
response, _ = ElasticWrap(self.es_search).get(self.data)
|
||||||
|
process_aggs(response)
|
||||||
results = SearchProcess(response).process()
|
results = SearchProcess(response).process()
|
||||||
max_hits = response["hits"]["total"]["value"]
|
max_hits = response["hits"]["total"]["value"]
|
||||||
self.pagination_handler.validate(max_hits)
|
self.pagination_handler.validate(max_hits)
|
||||||
|
|||||||
Reference in New Issue
Block a user