mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-04 22:59:39 +00:00
handle empty aggs
This commit is contained in:
@@ -55,6 +55,8 @@ class Video(AggBase):
|
|||||||
def process(self):
|
def process(self):
|
||||||
"""process aggregation"""
|
"""process aggregation"""
|
||||||
aggregations = self.get()
|
aggregations = self.get()
|
||||||
|
if not aggregations:
|
||||||
|
return None
|
||||||
|
|
||||||
duration = int(aggregations["duration"]["value"])
|
duration = int(aggregations["duration"]["value"])
|
||||||
response = {
|
response = {
|
||||||
@@ -109,6 +111,8 @@ class Channel(AggBase):
|
|||||||
def process(self):
|
def process(self):
|
||||||
"""process aggregation"""
|
"""process aggregation"""
|
||||||
aggregations = self.get()
|
aggregations = self.get()
|
||||||
|
if not aggregations:
|
||||||
|
return None
|
||||||
|
|
||||||
response = {
|
response = {
|
||||||
"doc_count": aggregations["channel_count"].get("value"),
|
"doc_count": aggregations["channel_count"].get("value"),
|
||||||
@@ -140,6 +144,9 @@ class Playlist(AggBase):
|
|||||||
def process(self):
|
def process(self):
|
||||||
"""process aggregation"""
|
"""process aggregation"""
|
||||||
aggregations = self.get()
|
aggregations = self.get()
|
||||||
|
if not aggregations:
|
||||||
|
return None
|
||||||
|
|
||||||
response = {"doc_count": aggregations["playlist_count"].get("value")}
|
response = {"doc_count": aggregations["playlist_count"].get("value")}
|
||||||
for bucket in aggregations["playlist_active"]["buckets"]:
|
for bucket in aggregations["playlist_active"]["buckets"]:
|
||||||
key = f"active_{bucket['key_as_string']}"
|
key = f"active_{bucket['key_as_string']}"
|
||||||
@@ -171,6 +178,9 @@ class Download(AggBase):
|
|||||||
"""process aggregation"""
|
"""process aggregation"""
|
||||||
aggregations = self.get()
|
aggregations = self.get()
|
||||||
response = {}
|
response = {}
|
||||||
|
if not aggregations:
|
||||||
|
return None
|
||||||
|
|
||||||
for bucket in aggregations["status"]["buckets"]:
|
for bucket in aggregations["status"]["buckets"]:
|
||||||
response.update({bucket["key"]: bucket.get("doc_count")})
|
response.update({bucket["key"]: bucket.get("doc_count")})
|
||||||
|
|
||||||
@@ -209,9 +219,11 @@ class WatchProgress(AggBase):
|
|||||||
def process(self):
|
def process(self):
|
||||||
"""make the call"""
|
"""make the call"""
|
||||||
aggregations = self.get()
|
aggregations = self.get()
|
||||||
buckets = aggregations[self.name]["buckets"]
|
|
||||||
|
|
||||||
response = {}
|
response = {}
|
||||||
|
if not aggregations:
|
||||||
|
return None
|
||||||
|
|
||||||
|
buckets = aggregations[self.name]["buckets"]
|
||||||
all_duration = int(aggregations["total_duration"].get("value"))
|
all_duration = int(aggregations["total_duration"].get("value"))
|
||||||
response.update(
|
response.update(
|
||||||
{
|
{
|
||||||
@@ -287,6 +299,9 @@ class DownloadHist(AggBase):
|
|||||||
def process(self):
|
def process(self):
|
||||||
"""process query"""
|
"""process query"""
|
||||||
aggregations = self.get()
|
aggregations = self.get()
|
||||||
|
if not aggregations:
|
||||||
|
return None
|
||||||
|
|
||||||
buckets = aggregations[self.name]["buckets"]
|
buckets = aggregations[self.name]["buckets"]
|
||||||
|
|
||||||
response = [
|
response = [
|
||||||
@@ -334,6 +349,9 @@ class BiggestChannel(AggBase):
|
|||||||
"""process aggregation, order_by validated in the view"""
|
"""process aggregation, order_by validated in the view"""
|
||||||
|
|
||||||
aggregations = self.get()
|
aggregations = self.get()
|
||||||
|
if not aggregations:
|
||||||
|
return None
|
||||||
|
|
||||||
buckets = aggregations[self.name]["buckets"]
|
buckets = aggregations[self.name]["buckets"]
|
||||||
|
|
||||||
response = [
|
response = [
|
||||||
|
|||||||
Reference in New Issue
Block a user