diff --git a/tubearchivist/api/src/aggs.py b/tubearchivist/api/src/aggs.py
index aac96f0..f8724df 100644
--- a/tubearchivist/api/src/aggs.py
+++ b/tubearchivist/api/src/aggs.py
@@ -31,11 +31,13 @@ class Primary(AggBase):
data = {
"size": 0,
"aggs": {
- "video_type": {"terms": {"field": "vid_type"}},
- "video_total": {"value_count": {"field": "media_url"}},
- "channel_total": {"value_count": {"field": "channel_id"}},
+ "video_type": {
+ "filter": {"exists": {"field": "active"}},
+ "aggs": {"filtered": {"terms": {"field": "vid_type"}}},
+ },
+ "channel_total": {"value_count": {"field": "channel_active"}},
"channel_sub": {"terms": {"field": "channel_subscribed"}},
- "playlist_total": {"value_count": {"field": "playlist_id"}},
+ "playlist_total": {"value_count": {"field": "playlist_active"}},
"playlist_sub": {"terms": {"field": "playlist_subscribed"}},
"download": {"terms": {"field": "status"}},
},
@@ -45,11 +47,11 @@ class Primary(AggBase):
"""make the call"""
aggregations = self.get()
- videos = {"total": aggregations["video_total"].get("value")}
+ videos = {"total": aggregations["video_type"].get("doc_count")}
videos.update(
{
i.get("key"): i.get("doc_count")
- for i in aggregations["video_type"]["buckets"]
+ for i in aggregations["video_type"]["filtered"]["buckets"]
}
)
channels = {"total": aggregations["channel_total"].get("value")}
diff --git a/tubearchivist/home/templates/home/settings.html b/tubearchivist/home/templates/home/settings.html
index d9e1860..8d605f7 100644
--- a/tubearchivist/home/templates/home/settings.html
+++ b/tubearchivist/home/templates/home/settings.html
@@ -2,10 +2,14 @@
{% load static %}
{% block settings_content %}
-
Dashboard Coming Soon
+ Your Archive
-
-
Tube Archivist settings have been moved to their own pages!
-
You can now find them by selecting an item from the sub-menu at the top of the page.
+
+
+
+
+
{% endblock settings_content %}
diff --git a/tubearchivist/static/css/style.css b/tubearchivist/static/css/style.css
index 74b3285..df9dfad 100644
--- a/tubearchivist/static/css/style.css
+++ b/tubearchivist/static/css/style.css
@@ -643,6 +643,10 @@ video:-webkit-full-screen {
background-color: var(--highlight-bg);
}
+.info-box-4 {
+ grid-template-columns: 1fr 1fr 1fr 1fr;
+}
+
.info-box-3 {
grid-template-columns: 1fr 1fr 1fr;
}
diff --git a/tubearchivist/static/stats.js b/tubearchivist/static/stats.js
new file mode 100644
index 0000000..eecf18b
--- /dev/null
+++ b/tubearchivist/static/stats.js
@@ -0,0 +1,77 @@
+// build stats for settings page
+
+'use strict';
+
+/* globals apiRequest */
+
+function primaryStats() {
+ let apiEndpoint = '/api/stats/primary/';
+ let responseData = apiRequest(apiEndpoint, 'GET');
+ let primaryBox = document.getElementById('primaryBox');
+ let videoTile = buildVideoTile(responseData);
+ primaryBox.appendChild(videoTile);
+ let channelTile = buildChannelTile(responseData);
+ primaryBox.appendChild(channelTile);
+ let playlistTile = buildPlaylistTile(responseData);
+ primaryBox.appendChild(playlistTile);
+ let downloadTile = buildDownloadTile(responseData);
+ primaryBox.appendChild(downloadTile);
+}
+
+function buildTile(titleText) {
+ let tile = document.createElement('div');
+ tile.classList.add('info-box-item');
+ let title = document.createElement('h3');
+ title.innerText = titleText;
+ tile.appendChild(title);
+ return tile;
+}
+
+function buildVideoTile(responseData) {
+ let tile = buildTile(`Total Videos: ${responseData.videos.total || 0}`);
+ let message = document.createElement('p');
+ message.innerHTML = `
+ videos: ${responseData.videos.videos || 0}
+ shorts: ${responseData.videos.shorts || 0}
+ streams: ${responseData.videos.streams || 0}
+ `;
+ tile.appendChild(message);
+
+ return tile;
+}
+
+function buildChannelTile(responseData) {
+ let tile = buildTile(`Total Channels: ${responseData.channels.total || 0}`);
+ let message = document.createElement('p');
+ message.innerHTML = `subscribed: ${responseData.channels.sub_true || 0}`;
+ tile.appendChild(message);
+
+ return tile;
+}
+
+function buildPlaylistTile(responseData) {
+ let tile = buildTile(`Total Playlists: ${responseData.playlists.total || 0}`);
+ let message = document.createElement('p');
+ message.innerHTML = `subscribed: ${responseData.playlists.sub_true || 0}`;
+ tile.appendChild(message);
+
+ return tile;
+}
+
+function buildDownloadTile(responseData) {
+ let tile = buildTile('Downloads');
+ let message = document.createElement('p');
+ message.innerHTML = `
+ pending: ${responseData.downloads.pending || 0}
+ ignored: ${responseData.downloads.ignore || 0}
+ `;
+ tile.appendChild(message);
+
+ return tile;
+}
+
+function buildStats() {
+ primaryStats();
+}
+
+buildStats();