Compare commits
No commits in common. "311fd89a549eef01cb685ab31af4ae7b360d1d3c" and "d3743d26852256da89f98f90a35aef3ba857f683" have entirely different histories.
311fd89a54
...
d3743d2685
35
analytics.py
35
analytics.py
@ -249,33 +249,20 @@ def return_folder_yesterday():
|
|||||||
|
|
||||||
|
|
||||||
def return_file_access():
|
def return_file_access():
|
||||||
"""Return recent audio file access logs from memory (the last 10 minutes)."""
|
"""Return recent file access logs from memory (the last 10 minutes)."""
|
||||||
global file_access_temp
|
global file_access_temp
|
||||||
|
if file_access_temp:
|
||||||
def is_audio(entry):
|
# Create a timezone-aware cutoff time
|
||||||
"""Check whether a log entry references an audio file."""
|
cutoff_time = datetime.now(timezone.utc).astimezone() - timedelta(minutes=10)
|
||||||
mime_val = (entry[3] or "").lower()
|
# Only keep entries with timestamps greater than or equal to cutoff_time
|
||||||
if mime_val.startswith("audio/"):
|
file_access_temp[:] = [
|
||||||
return True
|
entry for entry in file_access_temp
|
||||||
path_val = (entry[1] or "").lower()
|
if datetime.fromisoformat(entry[0]) >= cutoff_time
|
||||||
return path_val.endswith((
|
]
|
||||||
".mp3", ".wav", ".flac", ".m4a", ".aac",
|
return file_access_temp
|
||||||
".ogg", ".wma", ".aiff", ".alac", ".opus"
|
else:
|
||||||
))
|
|
||||||
|
|
||||||
if not file_access_temp:
|
|
||||||
return []
|
return []
|
||||||
|
|
||||||
# Create a timezone-aware cutoff time
|
|
||||||
cutoff_time = datetime.now(timezone.utc).astimezone() - timedelta(minutes=10)
|
|
||||||
# Only keep entries with timestamps greater than or equal to cutoff_time
|
|
||||||
file_access_temp[:] = [
|
|
||||||
entry for entry in file_access_temp
|
|
||||||
if datetime.fromisoformat(entry[0]) >= cutoff_time
|
|
||||||
]
|
|
||||||
# Only expose audio file accesses to the UI
|
|
||||||
return [entry for entry in file_access_temp if is_audio(entry)]
|
|
||||||
|
|
||||||
|
|
||||||
def return_file_access_with_geo():
|
def return_file_access_with_geo():
|
||||||
"""Return recent file access logs with geographic coordinates from the database."""
|
"""Return recent file access logs with geographic coordinates from the database."""
|
||||||
|
|||||||
10
app.py
10
app.py
@ -799,16 +799,6 @@ def serve_file(subpath):
|
|||||||
else:
|
else:
|
||||||
cache = cache_other
|
cache = cache_other
|
||||||
|
|
||||||
# Plain HEAD requests (without X-Cache-Request) should not populate the cache.
|
|
||||||
# They are just probes and would otherwise turn the first real GET into a “cached hit”.
|
|
||||||
if request.method == 'HEAD' and not is_cache_request:
|
|
||||||
response = make_response('', 200)
|
|
||||||
response.headers['Content-Type'] = mime
|
|
||||||
response.headers['Content-Length'] = str(filesize)
|
|
||||||
response.headers['Accept-Ranges'] = 'bytes'
|
|
||||||
response.headers['Cache-Control'] = 'public, max-age=86400'
|
|
||||||
return response
|
|
||||||
|
|
||||||
# 4) Image and thumbnail handling first
|
# 4) Image and thumbnail handling first
|
||||||
if mime.startswith('image/'):
|
if mime.startswith('image/'):
|
||||||
small = request.args.get('thumbnail') == 'true'
|
small = request.args.get('thumbnail') == 'true'
|
||||||
|
|||||||
@ -101,8 +101,7 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="page-content">
|
<div class="page-content">
|
||||||
<div class="section-header">
|
<div class="section-header">
|
||||||
<h2 style="margin: 0;">Verbindungen der letzten 10 Minuten (nur Audio)</h2>
|
<h2 style="margin: 0;">Verbindungen der letzten 10 Minuten</h2>
|
||||||
<p class="text-muted" style="margin: 4px 0 0 0;">Diese Ansicht listet ausschließlich Zugriffe auf Audio-Dateien.</p>
|
|
||||||
<div class="stats">
|
<div class="stats">
|
||||||
<div class="stat-item">
|
<div class="stat-item">
|
||||||
<div class="stat-label">Last Connection</div>
|
<div class="stat-label">Last Connection</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user