diff --git a/server/mergin/auth/api.yaml b/server/mergin/auth/api.yaml index e400fbfd..df924109 100644 --- a/server/mergin/auth/api.yaml +++ b/server/mergin/auth/api.yaml @@ -934,9 +934,9 @@ components: description: total number of projects example: 12 storage: - type: string + type: number description: projest files size in bytes - example: 1024 kB + example: 1024 users: type: integer description: count of registered accounts diff --git a/server/mergin/sync/utils.py b/server/mergin/sync/utils.py index 9efcd284..b4120acc 100644 --- a/server/mergin/sync/utils.py +++ b/server/mergin/sync/utils.py @@ -333,7 +333,7 @@ def files_size(): LEFT OUTER JOIN file_history fh ON fh.id = lf.file_id WHERE fh.change = 'update_diff'::push_change_type ) - SELECT pg_size_pretty(COALESCE(SUM(sum), 0)) FROM partials; + SELECT COALESCE(SUM(sum), 0) FROM partials; """ ) return db.session.execute(files_size).scalar() diff --git a/server/mergin/sync/workspace.py b/server/mergin/sync/workspace.py index 3f2bc397..8cc0a27a 100644 --- a/server/mergin/sync/workspace.py +++ b/server/mergin/sync/workspace.py @@ -355,7 +355,7 @@ def project_access(self, project: Project) -> List[ProjectAccessDetail]: def server_editors_count(self) -> int: if Configuration.GLOBAL_ADMIN or Configuration.GLOBAL_WRITE: return User.query.filter( - is_(User.username.ilike("deleted_%"), False) | User.active, + is_(User.username.ilike("deleted_%"), False), ).count() return ( diff --git a/server/mergin/tests/test_auth.py b/server/mergin/tests/test_auth.py index 569def6e..71a35e29 100644 --- a/server/mergin/tests/test_auth.py +++ b/server/mergin/tests/test_auth.py @@ -3,6 +3,7 @@ # SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-MerginMaps-Commercial from datetime import datetime, timedelta +import os import pytest import json from flask import url_for @@ -30,6 +31,7 @@ login_as_admin, login, upload_file_to_project, + test_project_dir, ) @@ -853,6 +855,9 @@ def test_server_usage(client): """Test server usage endpoint""" login_as_admin(client) workspace = create_workspace() + init_project = Project.query.filter_by(workspace_id=workspace.id).first() + resp = client.get("/app/admin/usage") + print(resp.json) user = add_user() admin = User.query.filter_by(username="mergin").first() # create new project @@ -865,7 +870,7 @@ def test_server_usage(client): assert resp.json["users"] == 2 assert resp.json["workspaces"] == 1 assert resp.json["projects"] == 2 - assert resp.json["storage"] == "454 kB" + assert resp.json["storage"] == project.disk_usage + init_project.disk_usage assert resp.json["active_monthly_contributors"] == 1 assert resp.json["editors"] == 1 project.set_role(user.id, ProjectRole.EDITOR) diff --git a/web-app/packages/admin-lib/src/modules/admin/views/OverviewView.vue b/web-app/packages/admin-lib/src/modules/admin/views/OverviewView.vue index 36bf6211..39bacdec 100644 --- a/web-app/packages/admin-lib/src/modules/admin/views/OverviewView.vue +++ b/web-app/packages/admin-lib/src/modules/admin/views/OverviewView.vue @@ -31,15 +31,17 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-MerginMaps-Commercial
{{ + $filters.filesize(usage.storage, null, 0) + }}
@@ -98,14 +100,6 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-MerginMaps-Commercial >{{ usage?.active_monthly_contributors }} -