mirror of
https://github.com/tubearchivist/tubearchivist
synced 2024-11-19 15:25:51 +00:00
add download history stats
This commit is contained in:
parent
5ee37eb0cb
commit
4016e81f9a
@ -174,7 +174,7 @@ class DownloadHist(AggBase):
|
||||
},
|
||||
}
|
||||
},
|
||||
"query": {"range": {"date_downloaded": {"gte": "now-6d/d"}}},
|
||||
"query": {"range": {"date_downloaded": {"gte": "now-7d/d"}}},
|
||||
}
|
||||
|
||||
def process(self):
|
||||
@ -182,7 +182,15 @@ class DownloadHist(AggBase):
|
||||
aggregations = self.get()
|
||||
buckets = aggregations[self.name]["buckets"]
|
||||
|
||||
return {i.get("key_as_string"): i.get("doc_count") for i in buckets}
|
||||
response = [
|
||||
{
|
||||
"date": i.get("key_as_string"),
|
||||
"count": i.get("doc_count"),
|
||||
}
|
||||
for i in buckets
|
||||
]
|
||||
|
||||
return response
|
||||
|
||||
|
||||
class BiggestChannel(AggBase):
|
||||
|
@ -4,15 +4,19 @@
|
||||
<div class="title-bar">
|
||||
<h1>Your Archive</h1>
|
||||
</div>
|
||||
<div>
|
||||
<div class="settings-item">
|
||||
<h2>Main overview</h2>
|
||||
<div id="primaryBox" class="info-box info-box-4"></div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="settings-item">
|
||||
<h2>Watch Progress</h2>
|
||||
<div id="watchBox" class="info-box info-box-3"></div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="settings-item">
|
||||
<h2>Download History</h2>
|
||||
<div id="downHistBox" class="info-box info-box-4"></div>
|
||||
</div>
|
||||
<div class="settings-item">
|
||||
<h2>Biggest Channels</h2>
|
||||
<div class="info-box description-box">
|
||||
<table>
|
||||
|
@ -96,6 +96,25 @@ function buildWatchTile(title, watchDetail) {
|
||||
return tile;
|
||||
}
|
||||
|
||||
function downloadHist() {
|
||||
let apiEndpoint = '/api/stats/downloadhist/';
|
||||
let responseData = apiRequest(apiEndpoint, 'GET');
|
||||
let histBox = document.getElementById('downHistBox');
|
||||
for (let i = 0; i < responseData.length; i++) {
|
||||
const dailyStat = responseData[i];
|
||||
let tile = buildDailyStat(dailyStat);
|
||||
histBox.appendChild(tile);
|
||||
}
|
||||
}
|
||||
|
||||
function buildDailyStat(dailyStat) {
|
||||
let tile = buildTile(dailyStat.date);
|
||||
let message = document.createElement('p');
|
||||
message.innerText = `new videos: ${dailyStat.count}`;
|
||||
tile.appendChild(message);
|
||||
return tile;
|
||||
}
|
||||
|
||||
function biggestChannel() {
|
||||
let apiEndpoint = '/api/stats/biggestchannels/';
|
||||
let responseData = apiRequest(apiEndpoint, 'GET');
|
||||
@ -126,6 +145,7 @@ function humanFileSize(size) {
|
||||
function buildStats() {
|
||||
primaryStats();
|
||||
watchStats();
|
||||
downloadHist();
|
||||
biggestChannel();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user