Merge pull request #580 from tcely/patch-2

Report db.sqlite3 size on dashboard
This commit is contained in:
meeb 2025-01-25 02:02:47 +11:00 committed by GitHub
commit 3130ff2816
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -125,7 +125,7 @@
</tr>
<tr title="Database connection used by TubeSync">
<td class="hide-on-small-only">Database</td>
<td><span class="hide-on-med-and-up">Database<br></span><strong>{{ database_connection }}</strong></td>
<td><span class="hide-on-med-and-up">Database<br></span><strong>{{ database_connection }}{% if database_filesize %} {{ database_filesize|filesizeformat }}{% endif %}</strong></td>
</tr>
</table>
</div>

View File

@ -14,7 +14,7 @@ from django.views.generic.detail import SingleObjectMixin
from django.core.exceptions import SuspiciousFileOperation
from django.http import HttpResponse
from django.urls import reverse_lazy
from django.db import IntegrityError
from django.db import connection, IntegrityError
from django.db.models import Q, Count, Sum, When, Case
from django.forms import Form, ValidationError
from django.utils.text import slugify
@ -85,6 +85,12 @@ class DashboardView(TemplateView):
data['config_dir'] = str(settings.CONFIG_BASE_DIR)
data['downloads_dir'] = str(settings.DOWNLOAD_ROOT)
data['database_connection'] = settings.DATABASE_CONNECTION_STR
# Add the database filesize when using db.sqlite3
data['database_filesize'] = None
db_name = str(connection.get_connection_params()['database'])
db_path = pathlib.Path(db_name) if '/' == db_name[0] else None
if db_path and 'sqlite' == connection.vendor:
data['database_filesize'] = db_path.stat().st_size
return data