Aggregation daily stats improvements, #build
Changed: - [API] make daily stats TZ aware - [API] add daily download media size
This commit is contained in:
commit
1657c55cbe
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
from home.src.es.connect import ElasticWrap
|
from home.src.es.connect import ElasticWrap
|
||||||
from home.src.ta.helper import get_duration_str
|
from home.src.ta.helper import get_duration_str
|
||||||
|
from home.src.ta.settings import EnvironmentSettings
|
||||||
|
|
||||||
|
|
||||||
class AggBase:
|
class AggBase:
|
||||||
|
@ -168,13 +169,22 @@ class DownloadHist(AggBase):
|
||||||
"calendar_interval": "day",
|
"calendar_interval": "day",
|
||||||
"format": "yyyy-MM-dd",
|
"format": "yyyy-MM-dd",
|
||||||
"order": {"_key": "desc"},
|
"order": {"_key": "desc"},
|
||||||
|
"time_zone": EnvironmentSettings.TZ,
|
||||||
},
|
},
|
||||||
"aggs": {
|
"aggs": {
|
||||||
"total_videos": {"value_count": {"field": "youtube_id"}}
|
"total_videos": {"value_count": {"field": "youtube_id"}},
|
||||||
|
"media_size": {"sum": {"field": "media_size"}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"query": {"range": {"date_downloaded": {"gte": "now-7d/d"}}},
|
"query": {
|
||||||
|
"range": {
|
||||||
|
"date_downloaded": {
|
||||||
|
"gte": "now-7d/d",
|
||||||
|
"time_zone": EnvironmentSettings.TZ,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
def process(self):
|
def process(self):
|
||||||
|
@ -186,6 +196,7 @@ class DownloadHist(AggBase):
|
||||||
{
|
{
|
||||||
"date": i.get("key_as_string"),
|
"date": i.get("key_as_string"),
|
||||||
"count": i.get("doc_count"),
|
"count": i.get("doc_count"),
|
||||||
|
"media_size": i["media_size"].get("value"),
|
||||||
}
|
}
|
||||||
for i in buckets
|
for i in buckets
|
||||||
]
|
]
|
||||||
|
|
|
@ -241,7 +241,9 @@ function buildDailyStat(dailyStat) {
|
||||||
text = 'Video';
|
text = 'Video';
|
||||||
}
|
}
|
||||||
|
|
||||||
message.innerText = `+${dailyStat.count} ${text}`;
|
message.innerText =
|
||||||
|
`+${dailyStat.count} ${text}
|
||||||
|
${humanFileSize(dailyStat.media_size)}`;
|
||||||
|
|
||||||
tile.appendChild(message);
|
tile.appendChild(message);
|
||||||
return tile;
|
return tile;
|
||||||
|
|
Loading…
Reference in New Issue