Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 2 additions & 109 deletions Tekst-API/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2947,55 +2947,6 @@
]
}
},
"/platform/stats": {
"get": {
"tags": [
"platform"
],
"summary": "Get statistics",
"operationId": "getStatistics",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PlatformStats"
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TekstErrorModel"
}
}
}
},
"403": {
"description": "Forbidden",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TekstErrorModel"
}
}
}
}
},
"security": [
{
"APIKeyCookie": []
},
{
"OAuth2PasswordBearer": []
}
]
}
},
"/platform/tasks": {
"get": {
"tags": [
Expand Down Expand Up @@ -3278,8 +3229,8 @@
"tags": [
"resources"
],
"summary": "Trigger resources maintenance",
"operationId": "triggerResourcesMaintenance",
"summary": "Trigger precomputation",
"operationId": "triggerPrecomputation",
"responses": {
"202": {
"description": "Successful Response",
Expand Down Expand Up @@ -14166,28 +14117,6 @@
"type": "object",
"title": "PlatformStateUpdate"
},
"PlatformStats": {
"properties": {
"usersCount": {
"type": "integer",
"title": "Userscount"
},
"texts": {
"items": {
"$ref": "#/components/schemas/TextStats"
},
"type": "array",
"title": "Texts"
}
},
"type": "object",
"required": [
"usersCount",
"texts"
],
"title": "PlatformStats",
"description": "Platform statistics data"
},
"PrivateUserProp": {
"type": "string",
"enum": [
Expand Down Expand Up @@ -16884,42 +16813,6 @@
],
"title": "TextRead"
},
"TextStats": {
"properties": {
"id": {
"type": "string",
"maxLength": 24,
"minLength": 24,
"pattern": "^[0-9a-f]{24}$",
"title": "Id",
"example": "5eb7cf5a86d9755df3a6c593"
},
"locationsCount": {
"type": "integer",
"title": "Locationscount"
},
"resourcesCount": {
"type": "integer",
"title": "Resourcescount"
},
"resourceTypes": {
"additionalProperties": {
"type": "integer"
},
"type": "object",
"title": "Resourcetypes"
}
},
"type": "object",
"required": [
"id",
"locationsCount",
"resourcesCount",
"resourceTypes"
],
"title": "TextStats",
"description": "Text statistics data"
},
"TextSubtitleTranslation": {
"properties": {
"locale": {
Expand Down
16 changes: 0 additions & 16 deletions Tekst-API/tekst/models/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,19 +263,3 @@ class PlatformData(ModelBase):
info_segments: list[ClientSegmentHead]
tekst: dict[str, str]
max_field_mappings: int


class TextStats(ModelBase):
"""Text statistics data"""

id: PydanticObjectId
locations_count: int
resources_count: int
resource_types: dict[str, int]


class PlatformStats(ModelBase):
"""Platform statistics data"""

users_count: int
texts: list[TextStats]
52 changes: 0 additions & 52 deletions Tekst-API/tekst/routers/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,21 @@
from tekst import errors, tasks
from tekst.auth import OptionalUserDep, SuperuserDep
from tekst.config import ConfigDep
from tekst.models.location import LocationDocument
from tekst.models.platform import (
PlatformData,
PlatformSecurityInfo,
PlatformStateDocument,
PlatformStateRead,
PlatformStateUpdate,
PlatformStats,
TextStats,
)
from tekst.models.resource import ResourceBaseDocument
from tekst.models.segment import (
ClientSegmentCreate,
ClientSegmentDocument,
ClientSegmentHead,
ClientSegmentRead,
ClientSegmentUpdate,
)
from tekst.models.text import TextDocument
from tekst.models.user import UserDocument
from tekst.resources import resource_types_mgr
from tekst.routers.texts import get_all_texts
from tekst.state import get_state, update_state

Expand Down Expand Up @@ -200,52 +194,6 @@ async def delete_segment(
raise errors.E_500_INTERNAL_SERVER_ERROR


@router.get(
"/stats",
response_model=PlatformStats,
status_code=status.HTTP_200_OK,
responses=errors.responses(
[
errors.E_401_UNAUTHORIZED,
errors.E_403_FORBIDDEN,
]
),
)
async def get_statistics(su: SuperuserDep) -> PlatformStats:
resource_type_names = resource_types_mgr.list_names()
texts = await TextDocument.find_all().to_list()
text_stats = []

for text in texts:
locations_count = await LocationDocument.find(
LocationDocument.text_id == text.id
).count()
resource_types = {
rt_name: (
await ResourceBaseDocument.find(
ResourceBaseDocument.text_id == text.id,
ResourceBaseDocument.resource_type == rt_name,
with_children=True,
).count()
)
for rt_name in resource_type_names
}
resources_count = sum(resource_types.values())
text_stats.append(
TextStats(
id=text.id,
locations_count=locations_count,
resources_count=resources_count,
resource_types=resource_types,
)
)

return PlatformStats(
users_count=await UserDocument.find_all().count(),
texts=text_stats,
)


@router.get(
"/tasks",
status_code=status.HTTP_200_OK,
Expand Down
2 changes: 1 addition & 1 deletion Tekst-API/tekst/routers/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ async def preprocess_resource_read(
]
),
)
async def trigger_resources_maintenance(
async def trigger_precomputation(
su: SuperuserDep,
) -> tasks.TaskDocument:
return await tasks.create_task(
Expand Down
15 changes: 0 additions & 15 deletions Tekst-API/tests/test_api_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,6 @@ async def test_platform_data(
assert resp.json()["tekst"]["version"] == package_metadata["version"]


@pytest.mark.anyio
async def test_get_stats(
test_client: AsyncClient,
assert_status,
login,
insert_sample_data,
):
await insert_sample_data("texts", "locations", "resources", "contents")
await login(is_superuser=True)
resp = await test_client.get("/platform/stats")
assert_status(200, resp)
assert "usersCount" in resp.json()
assert resp.json()["usersCount"] == 1


@pytest.mark.anyio
async def test_update_platform_settings(
test_client: AsyncClient,
Expand Down
3 changes: 0 additions & 3 deletions Tekst-Web/i18n/help/deDE/adminTextsLocationsView.md

This file was deleted.

3 changes: 0 additions & 3 deletions Tekst-Web/i18n/help/enUS/adminTextsLocationsView.md

This file was deleted.

Loading