mirror of
https://github.com/tubearchivist/tubearchivist
synced 2024-11-19 15:25:51 +00:00
Refac biggest channels to be 3 seperate tables with ordering and right align (#536)
* Add right align to numbers on biggest channels in dashboard * Refac biggest channels to be 3 seperate tables with ordering * Fix aggs linting
This commit is contained in:
parent
65d768bf02
commit
317942b7e1
@ -196,6 +196,9 @@ class DownloadHist(AggBase):
|
|||||||
class BiggestChannel(AggBase):
|
class BiggestChannel(AggBase):
|
||||||
"""get channel aggregations"""
|
"""get channel aggregations"""
|
||||||
|
|
||||||
|
def __init__(self, order):
|
||||||
|
self.data["aggs"][self.name]["multi_terms"]["order"] = {order: "desc"}
|
||||||
|
|
||||||
name = "channel_stats"
|
name = "channel_stats"
|
||||||
path = "ta_video/_search"
|
path = "ta_video/_search"
|
||||||
data = {
|
data = {
|
||||||
|
@ -1025,9 +1025,9 @@ class StatBiggestChannel(ApiBaseView):
|
|||||||
def get(self, request):
|
def get(self, request):
|
||||||
"""handle get request"""
|
"""handle get request"""
|
||||||
|
|
||||||
order = request.GET.get("order", False)
|
order = request.GET.get("order", "doc_count")
|
||||||
if order and order not in self.order_choices:
|
if order and order not in self.order_choices:
|
||||||
message = {"message": f"invalid order parameter {order}"}
|
message = {"message": f"invalid order parameter {order}"}
|
||||||
return Response(message, status=400)
|
return Response(message, status=400)
|
||||||
|
|
||||||
return Response(BiggestChannel().process())
|
return Response(BiggestChannel(order).process())
|
||||||
|
@ -22,21 +22,47 @@
|
|||||||
<p id="loading">Loading...</p>
|
<p id="loading">Loading...</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="settings-item">
|
<div class="settings-item">
|
||||||
<h2>Biggest Channels</h2>
|
<h2>Biggest Channels</h2>
|
||||||
<div class="info-box description-box">
|
<div class="info-box info-box-3">
|
||||||
<table>
|
<div class="info-box-item">
|
||||||
<thead>
|
<table class="agg-channel-table">
|
||||||
<tr>
|
<thead>
|
||||||
<th class="agg-channel-name">Name</th>
|
<tr>
|
||||||
<th>Videos</th>
|
<th>Name</th>
|
||||||
<th>Duration</th>
|
<th class="agg-channel-right-align">Videos</th>
|
||||||
<th>Media Size</th>
|
</tr>
|
||||||
</tr>
|
</thead>
|
||||||
</thead>
|
<tbody id="biggestChannelTableVideos"></tbody>
|
||||||
<tbody id="biggestChannelTable"></tbody>
|
</table>
|
||||||
</table>
|
</div>
|
||||||
|
|
||||||
|
<div class="info-box-item">
|
||||||
|
<table class="agg-channel-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th class="agg-channel-right-align">Duration</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="biggestChannelTableDuration"></tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="info-box-item">
|
||||||
|
<table class="agg-channel-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th class="agg-channel-right-align">Media Size</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="biggestChannelTableMediaSize"></tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript" src="{% static 'stats.js' %}"></script>
|
<script type="text/javascript" src="{% static 'stats.js' %}"></script>
|
||||||
{% endblock settings_content %}
|
{% endblock settings_content %}
|
||||||
|
@ -1099,6 +1099,15 @@ video:-webkit-full-screen {
|
|||||||
min-width: 300px;
|
min-width: 300px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.settings-item .agg-channel-table {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-item .agg-channel-right-align {
|
||||||
|
white-space: nowrap;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
.danger-zone {
|
.danger-zone {
|
||||||
background-color: var(--highlight-error);
|
background-color: var(--highlight-error);
|
||||||
color: #fff;
|
color: #fff;
|
||||||
@ -1316,11 +1325,6 @@ video:-webkit-full-screen {
|
|||||||
.playlist-nav-item img {
|
.playlist-nav-item img {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
.agg-channel-name {
|
|
||||||
min-width: 50px;
|
|
||||||
width: 100px;
|
|
||||||
max-width: 200px;
|
|
||||||
}
|
|
||||||
.td, th, span, label {
|
.td, th, span, label {
|
||||||
text-align: unset;
|
text-align: unset;
|
||||||
}
|
}
|
||||||
|
@ -128,31 +128,71 @@ function buildDailyStat(dailyStat) {
|
|||||||
return tile;
|
return tile;
|
||||||
}
|
}
|
||||||
|
|
||||||
function biggestChannel() {
|
function humanFileSize(size) {
|
||||||
let apiEndpoint = '/api/stats/biggestchannels/';
|
let i = size === 0 ? 0 : Math.floor(Math.log(size) / Math.log(1024));
|
||||||
let responseData = apiRequest(apiEndpoint, 'GET');
|
return (size / Math.pow(1024, i)).toFixed(1) * 1 + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i];
|
||||||
let tBody = document.getElementById('biggestChannelTable');
|
}
|
||||||
|
|
||||||
|
function buildChannelRow(id, name, value) {
|
||||||
|
let tableRow = document.createElement('tr');
|
||||||
|
|
||||||
|
tableRow.innerHTML = `
|
||||||
|
<td class="agg-channel-name"><a href="/channel/${id}/">${name}</a></td>
|
||||||
|
<td class="agg-channel-right-align">${value}</td>
|
||||||
|
`;
|
||||||
|
|
||||||
|
return tableRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addBiggestChannelByDocCount() {
|
||||||
|
let tBody = document.getElementById('biggestChannelTableVideos');
|
||||||
|
|
||||||
|
let apiEndpoint = '/api/stats/biggestchannels/?order=doc_count';
|
||||||
|
const responseData = apiRequest(apiEndpoint, 'GET');
|
||||||
|
|
||||||
for (let i = 0; i < responseData.length; i++) {
|
for (let i = 0; i < responseData.length; i++) {
|
||||||
const channelData = responseData[i];
|
const { id, name, doc_count } = responseData[i];
|
||||||
let tableRow = buildChannelRow(channelData);
|
|
||||||
|
let tableRow = buildChannelRow(id, name, doc_count);
|
||||||
|
|
||||||
tBody.appendChild(tableRow);
|
tBody.appendChild(tableRow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildChannelRow(channelData) {
|
function addBiggestChannelByDuration() {
|
||||||
let tableRow = document.createElement('tr');
|
const tBody = document.getElementById('biggestChannelTableDuration');
|
||||||
tableRow.innerHTML = `
|
|
||||||
<td class="agg-channel-name"><a href="/channel/${channelData.id}/">${channelData.name}</a></td>
|
let apiEndpoint = '/api/stats/biggestchannels/?order=duration';
|
||||||
<td>${channelData.doc_count}</td>
|
const responseData = apiRequest(apiEndpoint, 'GET');
|
||||||
<td>${channelData.duration_str}</td>
|
|
||||||
<td>${humanFileSize(channelData.media_size)}</td>
|
for (let i = 0; i < responseData.length; i++) {
|
||||||
`;
|
const { id, name, duration_str } = responseData[i];
|
||||||
return tableRow;
|
|
||||||
|
let tableRow = buildChannelRow(id, name, duration_str);
|
||||||
|
|
||||||
|
tBody.appendChild(tableRow);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function humanFileSize(size) {
|
function addBiggestChannelByMediaSize() {
|
||||||
let i = size === 0 ? 0 : Math.floor(Math.log(size) / Math.log(1024));
|
let tBody = document.getElementById('biggestChannelTableMediaSize');
|
||||||
return (size / Math.pow(1024, i)).toFixed(1) * 1 + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i];
|
|
||||||
|
let apiEndpoint = '/api/stats/biggestchannels/?order=media_size';
|
||||||
|
const responseData = apiRequest(apiEndpoint, 'GET');
|
||||||
|
|
||||||
|
for (let i = 0; i < responseData.length; i++) {
|
||||||
|
const { id, name, media_size } = responseData[i];
|
||||||
|
|
||||||
|
let tableRow = buildChannelRow(id, name, humanFileSize(media_size));
|
||||||
|
|
||||||
|
tBody.appendChild(tableRow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function biggestChannel() {
|
||||||
|
addBiggestChannelByDocCount();
|
||||||
|
addBiggestChannelByDuration();
|
||||||
|
addBiggestChannelByMediaSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildStats() {
|
async function buildStats() {
|
||||||
|
Loading…
Reference in New Issue
Block a user