add primary aggs
This commit is contained in:
parent
d491b0b347
commit
505f5b73c5
|
@ -31,11 +31,13 @@ class Primary(AggBase):
|
||||||
data = {
|
data = {
|
||||||
"size": 0,
|
"size": 0,
|
||||||
"aggs": {
|
"aggs": {
|
||||||
"video_type": {"terms": {"field": "vid_type"}},
|
"video_type": {
|
||||||
"video_total": {"value_count": {"field": "media_url"}},
|
"filter": {"exists": {"field": "active"}},
|
||||||
"channel_total": {"value_count": {"field": "channel_id"}},
|
"aggs": {"filtered": {"terms": {"field": "vid_type"}}},
|
||||||
|
},
|
||||||
|
"channel_total": {"value_count": {"field": "channel_active"}},
|
||||||
"channel_sub": {"terms": {"field": "channel_subscribed"}},
|
"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"}},
|
"playlist_sub": {"terms": {"field": "playlist_subscribed"}},
|
||||||
"download": {"terms": {"field": "status"}},
|
"download": {"terms": {"field": "status"}},
|
||||||
},
|
},
|
||||||
|
@ -45,11 +47,11 @@ class Primary(AggBase):
|
||||||
"""make the call"""
|
"""make the call"""
|
||||||
aggregations = self.get()
|
aggregations = self.get()
|
||||||
|
|
||||||
videos = {"total": aggregations["video_total"].get("value")}
|
videos = {"total": aggregations["video_type"].get("doc_count")}
|
||||||
videos.update(
|
videos.update(
|
||||||
{
|
{
|
||||||
i.get("key"): i.get("doc_count")
|
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")}
|
channels = {"total": aggregations["channel_total"].get("value")}
|
||||||
|
|
|
@ -2,10 +2,14 @@
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% block settings_content %}
|
{% block settings_content %}
|
||||||
<div class="title-bar">
|
<div class="title-bar">
|
||||||
<h1>Dashboard Coming Soon</h1>
|
<h1>Your Archive</h1>
|
||||||
</div>
|
</div>
|
||||||
<div class="settings-group">
|
<div>
|
||||||
<p>Tube Archivist settings have been moved to their own pages!</p>
|
<h2>Main overview</h2>
|
||||||
<p>You can now find them by selecting an item from the sub-menu at the top of the page.</p>
|
<div id="primaryBox" class="info-box info-box-4"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript" src="{% static 'stats.js' %}"></script>
|
||||||
{% endblock settings_content %}
|
{% endblock settings_content %}
|
||||||
|
|
|
@ -643,6 +643,10 @@ video:-webkit-full-screen {
|
||||||
background-color: var(--highlight-bg);
|
background-color: var(--highlight-bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.info-box-4 {
|
||||||
|
grid-template-columns: 1fr 1fr 1fr 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
.info-box-3 {
|
.info-box-3 {
|
||||||
grid-template-columns: 1fr 1fr 1fr;
|
grid-template-columns: 1fr 1fr 1fr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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}<br>
|
||||||
|
shorts: ${responseData.videos.shorts || 0}<br>
|
||||||
|
streams: ${responseData.videos.streams || 0}<br>
|
||||||
|
`;
|
||||||
|
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}<br>
|
||||||
|
ignored: ${responseData.downloads.ignore || 0}<br>
|
||||||
|
`;
|
||||||
|
tile.appendChild(message);
|
||||||
|
|
||||||
|
return tile;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildStats() {
|
||||||
|
primaryStats();
|
||||||
|
}
|
||||||
|
|
||||||
|
buildStats();
|
Loading…
Reference in New Issue