mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-04 13:49:57 -05:00
Summarizing Channel size on Channels page, rather than info age.
This commit is contained in:
parent
f079263fad
commit
7c5caf1dfd
2 changed files with 10 additions and 14 deletions
|
|
@ -18,7 +18,6 @@ import {
|
||||||
DirectoryInput,
|
DirectoryInput,
|
||||||
frequencyOptions,
|
frequencyOptions,
|
||||||
humanFileSize,
|
humanFileSize,
|
||||||
isoDatetimeToString,
|
|
||||||
RequiredAsterisk,
|
RequiredAsterisk,
|
||||||
secondsToFrequency,
|
secondsToFrequency,
|
||||||
Toggle,
|
Toggle,
|
||||||
|
|
@ -450,10 +449,10 @@ function ChannelRow({channel}) {
|
||||||
{channel.video_count}
|
{channel.video_count}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
{channel.url && channel.info_date ? isoDatetimeToString(channel.info_date) : null}
|
{channel.url && channel.download_frequency ? secondsToFrequency(channel.download_frequency) : null}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
{channel.url && channel.download_frequency ? secondsToFrequency(channel.download_frequency) : null}
|
{channel.size ? humanFileSize(channel.size) : null}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell textAlign='right'>
|
<TableCell textAlign='right'>
|
||||||
<Link className={buttonClass} to={editTo}>Edit</Link>
|
<Link className={buttonClass} to={editTo}>Edit</Link>
|
||||||
|
|
@ -520,8 +519,8 @@ export function Channels() {
|
||||||
const headers = [
|
const headers = [
|
||||||
{key: 'name', text: 'Name', sortBy: 'name', width: 8},
|
{key: 'name', text: 'Name', sortBy: 'name', width: 8},
|
||||||
{key: 'video_count', text: 'Videos', sortBy: 'video_count', width: 2},
|
{key: 'video_count', text: 'Videos', sortBy: 'video_count', width: 2},
|
||||||
{key: 'last_update', text: 'Last Update', sortBy: 'info_date', width: 2},
|
|
||||||
{key: 'download_frequency', text: 'Download Frequency', sortBy: 'download_frequency', width: 2},
|
{key: 'download_frequency', text: 'Download Frequency', sortBy: 'download_frequency', width: 2},
|
||||||
|
{key: 'size', text: 'Size', sortBy: 'size', width: 2},
|
||||||
{key: 'manage', text: 'Manage', width: 2},
|
{key: 'manage', text: 'Manage', width: 2},
|
||||||
];
|
];
|
||||||
const mobileHeaders = [
|
const mobileHeaders = [
|
||||||
|
|
|
||||||
|
|
@ -26,20 +26,17 @@ async def get_minimal_channels() -> List[dict]:
|
||||||
# Get all channels, even if they don't have videos.
|
# Get all channels, even if they don't have videos.
|
||||||
stmt = '''
|
stmt = '''
|
||||||
SELECT
|
SELECT
|
||||||
c.id, name, directory, url, download_frequency, info_date,
|
c.id, name, directory, c.url, download_frequency,
|
||||||
(select next_download from download d where d.url=c.url) AS next_download
|
COUNT(v.id) as video_count,
|
||||||
|
SUM(fg.size)::BIGINT AS size
|
||||||
FROM
|
FROM
|
||||||
channel AS c
|
channel AS c
|
||||||
ORDER BY LOWER(name)
|
LEFT JOIN video v on c.id = v.channel_id
|
||||||
|
LEFT JOIN file_group fg on fg.id = v.file_group_id
|
||||||
|
GROUP BY 1, 2, 3, 4, 5
|
||||||
'''
|
'''
|
||||||
curs.execute(stmt)
|
curs.execute(stmt)
|
||||||
channels = list(map(dict, curs.fetchall()))
|
channels = sorted([dict(i) for i in curs.fetchall()], key=lambda i: i['name'].lower())
|
||||||
|
|
||||||
video_counts = await get_channels_video_count()
|
|
||||||
|
|
||||||
for channel in channels:
|
|
||||||
channel_id = channel['id']
|
|
||||||
channel['video_count'] = video_counts[channel_id]
|
|
||||||
|
|
||||||
return channels
|
return channels
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue