diff --git a/tubearchivist/api/src/aggs.py b/tubearchivist/api/src/aggs.py
index b8db502b..aa35c398 100644
--- a/tubearchivist/api/src/aggs.py
+++ b/tubearchivist/api/src/aggs.py
@@ -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):
diff --git a/tubearchivist/home/templates/home/settings.html b/tubearchivist/home/templates/home/settings.html
index edaaeaf0..3d2bafdb 100644
--- a/tubearchivist/home/templates/home/settings.html
+++ b/tubearchivist/home/templates/home/settings.html
@@ -4,15 +4,19 @@
Your Archive
-
+
-
+
-
+
+
Biggest Channels
diff --git a/tubearchivist/static/stats.js b/tubearchivist/static/stats.js
index 0bdba344..8a2616c7 100644
--- a/tubearchivist/static/stats.js
+++ b/tubearchivist/static/stats.js
@@ -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();
}