fix toplist folder

This commit is contained in:
lelo 2025-05-29 15:08:14 +02:00
parent 7dd107fc72
commit 9173247212
3 changed files with 14 additions and 14 deletions

13
app.py
View File

@ -279,17 +279,16 @@ def api_browse(subpath):
foldernames = [] foldernames = []
files = [] files = []
split_path = subpath.split('/') split_path = subpath.split('/')
if len(split_path) == 1 and split_path[0] == 'toplist': if len(split_path) == 1 and split_path[0] == 'toplist':
foldernames = [ foldernames = [
{'name': 'Predigten', 'path': 'toplist/predigt'}, {'name': 'Predigten', 'path': 'toplist/Predigt'},
{'name': 'Chorlieder', 'path': 'toplist/chor'}, {'name': 'Chorlieder', 'path': 'toplist/Chor'},
{'name': 'Gemeinsamer Gesang', 'path': 'toplist/gemeinsamer_gesang'}, {'name': 'Gemeinsamer Gesang', 'path': 'toplist/Gemeinsamer Gesang'},
{'name': 'Gruppengesang', 'path': 'toplist/gruppengesang'}, {'name': 'Gruppenlieder', 'path': 'toplist/Gruppenlied'},
] ]
elif len(split_path) > 1 and split_path[0] == 'toplist': elif len(split_path) > 1 and split_path[0] == 'toplist':
files = [ files = hf.generate_top_list(split_path[1])
hf.generate_top_list(split_path[1])
]
return jsonify({ return jsonify({
'breadcrumbs': generate_breadcrumbs(subpath), 'breadcrumbs': generate_breadcrumbs(subpath),

View File

@ -104,7 +104,7 @@ def generate_top_list(category):
start_str = start_dt.isoformat() start_str = start_dt.isoformat()
# Filter for mimes that start with the given type # Filter for mimes that start with the given type
params_for_filter = (start_str) params_for_filter = (start_str,)
# 1. Top files by access count # 1. Top files by access count
query = f''' query = f'''
@ -123,17 +123,18 @@ def generate_top_list(category):
rows = [ rows = [
{ {
'rel_path': rel_path, 'rel_path': rel_path,
'access_count': access_count,
'category': extract_structure_from_string(rel_path)[0] 'category': extract_structure_from_string(rel_path)[0]
} }
for rel_path in rows for rel_path, access_count in rows
] ]
rows = [r for r in rows if r['category'] == category][:20] rows = [r for r in rows if r['category'] == category][:20]
filelist = [ filelist = [
{ {
'name': rel_path, 'name': rel_path.split('/')[-1],
'path': rel_path 'path': rel_path,
'file_type': 'music'
} }
for rel_path in [r['rel_path'] for r in rows] for rel_path in [r['rel_path'] for r in rows]
] ]

View File

@ -117,7 +117,7 @@ function renderContent(data) {
contentHTML += `<li class="directory-item"><a href="#" class="directory-link" data-path="gestern">📅 Gestern</a></li>`; contentHTML += `<li class="directory-item"><a href="#" class="directory-link" data-path="gestern">📅 Gestern</a></li>`;
} }
if (data.breadcrumbs.length === 1 ) { if (data.breadcrumbs.length === 1 ) {
contentHTML += `<li class="directory-item"><a href="#" class="directory-link" data-path="toplist">👥 oft gehört</a></li>`; contentHTML += `<li class="directory-item"><a href="#" class="directory-link" data-path="toplist">🔥 oft angehört</a></li>`;
} }
console.log(data.folder_today, data.folder_yesterday); console.log(data.folder_today, data.folder_yesterday);
data.directories.forEach(dir => { data.directories.forEach(dir => {