welearn-database 1.4.5.dev0__tar.gz → 1.5.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/PKG-INFO +1 -1
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/pyproject.toml +1 -1
- welearn_database-1.5.1/welearn_database/alembic/versions/5aad97149044_add_histo_table_for_materialized_views.py +71 -0
- welearn_database-1.5.1/welearn_database/alembic/versions/6d4346fad6f4_view_used_feature_per_session.py +88 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/alembic/versions/8b780aea403a_add_university_data.py +4 -8
- welearn_database-1.5.1/welearn_database/alembic/versions/b84462ca3800_update_grafana_process_state_view.py +45 -0
- welearn_database-1.5.1/welearn_database/data/details_dict.py +30 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/data/enumeration.py +0 -6
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/data/models/document_related.py +62 -2
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/data/models/grafana.py +15 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/data/models/user_related.py +3 -18
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/LICENSE +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/README.md +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/__init__.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/alembic/README +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/alembic/env.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/alembic/script.py.mako +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/alembic/versions/068312e7800c_add_referrer_origin_column_to_user_and_.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/alembic/versions/0e0bc0fca384_doc_qty_per_source.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/alembic/versions/16ff997426d3_remove_error_retrieval_unique_constraint.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/alembic/versions/2ad4895b2674_data_collection.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/alembic/versions/4c7161819e5a_grafana_views.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/alembic/versions/4f5a188dd614_add_main_url_column.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/alembic/versions/4fcbfb7f3145_added_api_key_management_table.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/alembic/versions/5d82613c9aca_context_document.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/alembic/versions/821173cf9c5d_initial_migration.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/alembic/versions/84c42739c17b_create_table_errordataquality.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/alembic/versions/89920abb7ff8_add_category.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/alembic/versions/96bba9e4842a_merge_external_id_error_quality.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/alembic/versions/9b4f1da0c1f2_data_collection_for_focus_group.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/alembic/versions/a50a1db3ca2a_add_used_since_column_for_embeddings.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/alembic/versions/b031206324b7_agent_related.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/alembic/versions/b049924f7067_modify_corpus_name_embedding_model_lang_.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/alembic/versions/ccdbd708c997_create_column_external_id.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/alembic/versions/e354666f951d_inferred_user.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/alembic/versions/f1ce0ad2845b_add_doi_column_to_document.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/alembic/versions/f8602200fa99_update_session_view.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/data/__init__.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/data/models/__init__.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/data/models/agent_related.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/data/models/corpus_related.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/database_utils.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/exceptions.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/modules/__init__.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/modules/text_cleaning.py +0 -0
- {welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/regular_expression.py +0 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""add_histo_table_for_materialized_views
|
|
2
|
+
|
|
3
|
+
Revision ID: 5aad97149044
|
|
4
|
+
Revises: b84462ca3800
|
|
5
|
+
Create Date: 2026-06-17 11:31:55.292978
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from typing import Sequence, Union
|
|
10
|
+
|
|
11
|
+
import sqlalchemy as sa
|
|
12
|
+
from alembic import op
|
|
13
|
+
from sqlalchemy import text
|
|
14
|
+
from sqlalchemy.dialects import postgresql
|
|
15
|
+
|
|
16
|
+
# revision identifiers, used by Alembic.
|
|
17
|
+
revision: str = "5aad97149044"
|
|
18
|
+
down_revision: Union[str, None] = "b84462ca3800"
|
|
19
|
+
branch_labels: Union[str, Sequence[str], None] = None
|
|
20
|
+
depends_on: Union[str, Sequence[str], None] = None
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def upgrade() -> None:
|
|
24
|
+
op.create_table(
|
|
25
|
+
"historical_qty_document_per_corpus",
|
|
26
|
+
sa.Column(
|
|
27
|
+
"id", sa.Uuid(), server_default=text("gen_random_uuid()"), nullable=False
|
|
28
|
+
),
|
|
29
|
+
sa.Column("source_name", sa.String(), nullable=False),
|
|
30
|
+
sa.Column("quantity", sa.Integer(), nullable=False),
|
|
31
|
+
sa.Column(
|
|
32
|
+
"created_at", postgresql.TIMESTAMP(), server_default="NOW()", nullable=False
|
|
33
|
+
),
|
|
34
|
+
sa.PrimaryKeyConstraint("id"),
|
|
35
|
+
schema="document_related",
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
op.create_table(
|
|
39
|
+
"historical_qty_document_in_qdrant_per_corpus",
|
|
40
|
+
sa.Column(
|
|
41
|
+
"id", sa.Uuid(), server_default=text("gen_random_uuid()"), nullable=False
|
|
42
|
+
),
|
|
43
|
+
sa.Column("source_name", sa.String(), nullable=False),
|
|
44
|
+
sa.Column("quantity", sa.Integer(), nullable=False),
|
|
45
|
+
sa.Column(
|
|
46
|
+
"created_at", postgresql.TIMESTAMP(), server_default="NOW()", nullable=False
|
|
47
|
+
),
|
|
48
|
+
sa.PrimaryKeyConstraint("id"),
|
|
49
|
+
schema="document_related",
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
op.create_table(
|
|
53
|
+
"historical_qty_document_in_qdrant",
|
|
54
|
+
sa.Column(
|
|
55
|
+
"id", sa.Uuid(), server_default=text("gen_random_uuid()"), nullable=False
|
|
56
|
+
),
|
|
57
|
+
sa.Column("quantity", sa.Integer(), nullable=False),
|
|
58
|
+
sa.Column(
|
|
59
|
+
"created_at", postgresql.TIMESTAMP(), server_default="NOW()", nullable=False
|
|
60
|
+
),
|
|
61
|
+
sa.PrimaryKeyConstraint("id"),
|
|
62
|
+
schema="document_related",
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def downgrade() -> None:
|
|
67
|
+
op.drop_table("historical_qty_document_per_corpus", schema="document_related")
|
|
68
|
+
op.drop_table(
|
|
69
|
+
"historical_qty_document_in_qdrant_per_corpus", schema="document_related"
|
|
70
|
+
)
|
|
71
|
+
op.drop_table("historical_qty_document_in_qdrant", schema="document_related")
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"""view_used_feature_per_session
|
|
2
|
+
|
|
3
|
+
Revision ID: 6d4346fad6f4
|
|
4
|
+
Revises: 5aad97149044
|
|
5
|
+
Create Date: 2026-06-17 11:54:52.441998
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from typing import Sequence, Union
|
|
10
|
+
|
|
11
|
+
from alembic import op
|
|
12
|
+
|
|
13
|
+
# revision identifiers, used by Alembic.
|
|
14
|
+
revision: str = "6d4346fad6f4"
|
|
15
|
+
down_revision: Union[str, None] = "5aad97149044"
|
|
16
|
+
branch_labels: Union[str, Sequence[str], None] = None
|
|
17
|
+
depends_on: Union[str, Sequence[str], None] = None
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def upgrade() -> None:
|
|
21
|
+
op.execute("""
|
|
22
|
+
CREATE OR REPLACE VIEW grafana.used_feature_per_session
|
|
23
|
+
AS WITH matching_features_endpoint AS (
|
|
24
|
+
SELECT
|
|
25
|
+
endpoint_name,
|
|
26
|
+
feature_name
|
|
27
|
+
FROM
|
|
28
|
+
(
|
|
29
|
+
VALUES
|
|
30
|
+
('/api/v1/search/by_document', 'search'),
|
|
31
|
+
('/api/v1/qna/chat/answer', 'chat'),
|
|
32
|
+
('/api/v1/qna/chat/agent', 'chat'),
|
|
33
|
+
('/api/v1/tutor/syllabus', 'syllabus'),
|
|
34
|
+
('/api/v1/user/bookmarks/:document_id', 'bookmark'),
|
|
35
|
+
('/api/v1/user/:user_id/bookmarks/:document_id', 'bookmark')
|
|
36
|
+
) AS t(endpoint_name, feature_name)
|
|
37
|
+
),
|
|
38
|
+
session_feature_pair AS (
|
|
39
|
+
SELECT
|
|
40
|
+
DISTINCT
|
|
41
|
+
er.session_id,
|
|
42
|
+
mfe.feature_name
|
|
43
|
+
FROM
|
|
44
|
+
user_related.endpoint_request er
|
|
45
|
+
CROSS JOIN matching_features_endpoint mfe
|
|
46
|
+
ORDER BY
|
|
47
|
+
er.session_id
|
|
48
|
+
),
|
|
49
|
+
actual_count AS (
|
|
50
|
+
SELECT
|
|
51
|
+
er.session_id,
|
|
52
|
+
mfe.feature_name,
|
|
53
|
+
COUNT(1) AS cnt
|
|
54
|
+
FROM
|
|
55
|
+
user_related.endpoint_request er
|
|
56
|
+
INNER JOIN
|
|
57
|
+
user_related."session" s ON
|
|
58
|
+
s.id = er.session_id
|
|
59
|
+
INNER JOIN
|
|
60
|
+
matching_features_endpoint mfe ON
|
|
61
|
+
mfe.endpoint_name = er.endpoint_name
|
|
62
|
+
GROUP BY
|
|
63
|
+
er.session_id,
|
|
64
|
+
mfe.feature_name
|
|
65
|
+
)
|
|
66
|
+
SELECT
|
|
67
|
+
s.inferred_user_id,
|
|
68
|
+
sfp.session_id,
|
|
69
|
+
sfp.feature_name,
|
|
70
|
+
COALESCE(ac.cnt, 0) AS cnt,
|
|
71
|
+
COALESCE(ac.cnt, 0) > 0 AS is_feature_used,
|
|
72
|
+
s.created_at AS session_created_at
|
|
73
|
+
FROM
|
|
74
|
+
session_feature_pair sfp
|
|
75
|
+
LEFT JOIN actual_count ac ON
|
|
76
|
+
ac.feature_name = sfp.feature_name
|
|
77
|
+
AND ac.session_id = sfp.session_id
|
|
78
|
+
INNER JOIN user_related."session" s ON
|
|
79
|
+
s.id = sfp.session_id
|
|
80
|
+
ORDER BY
|
|
81
|
+
session_created_at
|
|
82
|
+
""")
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def downgrade() -> None:
|
|
86
|
+
op.execute("""
|
|
87
|
+
DROP VIEW IF EXISTS grafana.used_feature_per_session;
|
|
88
|
+
""")
|
|
@@ -20,6 +20,9 @@ depends_on: Union[str, Sequence[str], None] = None
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
def upgrade() -> None:
|
|
23
|
+
# op.execute("""
|
|
24
|
+
# CREATE TYPE user_related.university_role AS ENUM ('student', 'teacher', 'staff')
|
|
25
|
+
# """)
|
|
23
26
|
op.add_column(
|
|
24
27
|
"inferred_user",
|
|
25
28
|
sa.Column("university_title", sa.String(), nullable=True),
|
|
@@ -29,13 +32,7 @@ def upgrade() -> None:
|
|
|
29
32
|
"inferred_user",
|
|
30
33
|
sa.Column(
|
|
31
34
|
"role",
|
|
32
|
-
|
|
33
|
-
"student",
|
|
34
|
-
"teacher",
|
|
35
|
-
"staff",
|
|
36
|
-
name="university_role",
|
|
37
|
-
schema="user_related",
|
|
38
|
-
),
|
|
35
|
+
sa.String(),
|
|
39
36
|
nullable=True,
|
|
40
37
|
),
|
|
41
38
|
schema="user_related",
|
|
@@ -45,4 +42,3 @@ def upgrade() -> None:
|
|
|
45
42
|
def downgrade() -> None:
|
|
46
43
|
op.drop_column("inferred_user", "university_title", schema="user_related")
|
|
47
44
|
op.drop_column("inferred_user", "role", schema="user_related")
|
|
48
|
-
op.execute("DROP TYPE user_related.university_role")
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""update grafana process state view
|
|
2
|
+
|
|
3
|
+
Revision ID: b84462ca3800
|
|
4
|
+
Revises: 8b780aea403a
|
|
5
|
+
Create Date: 2026-06-04 16:56:18.693751
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from typing import Sequence, Union
|
|
10
|
+
|
|
11
|
+
import sqlalchemy as sa
|
|
12
|
+
from alembic import op
|
|
13
|
+
|
|
14
|
+
# revision identifiers, used by Alembic.
|
|
15
|
+
revision: str = "b84462ca3800"
|
|
16
|
+
down_revision: Union[str, None] = "8b780aea403a"
|
|
17
|
+
branch_labels: Union[str, Sequence[str], None] = None
|
|
18
|
+
depends_on: Union[str, Sequence[str], None] = None
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def upgrade() -> None:
|
|
22
|
+
op.execute("""
|
|
23
|
+
CREATE OR REPLACE VIEW grafana.process_state
|
|
24
|
+
AS SELECT process_state.id,
|
|
25
|
+
process_state.document_id,
|
|
26
|
+
process_state.title,
|
|
27
|
+
process_state.created_at,
|
|
28
|
+
process_state.operation_order,
|
|
29
|
+
corpus.source_name
|
|
30
|
+
FROM document_related.process_state
|
|
31
|
+
JOIN document_related.welearn_document ON welearn_document.id = process_state.document_id
|
|
32
|
+
JOIN corpus_related.corpus ON welearn_document.corpus_id = corpus.id;
|
|
33
|
+
""")
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def downgrade() -> None:
|
|
37
|
+
op.execute("""
|
|
38
|
+
CREATE OR REPLACE VIEW grafana.process_state
|
|
39
|
+
AS SELECT process_state.id,
|
|
40
|
+
process_state.document_id,
|
|
41
|
+
process_state.title,
|
|
42
|
+
process_state.created_at,
|
|
43
|
+
process_state.operation_order,
|
|
44
|
+
FROM document_related.process_state;
|
|
45
|
+
""")
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from dataclasses import asdict, is_dataclass
|
|
2
|
+
|
|
3
|
+
from sqlalchemy import types
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class DetailsDict(types.TypeDecorator):
|
|
7
|
+
"""
|
|
8
|
+
Convert dataclass instances into dictionaries for JSON storage.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
impl = types.JSON
|
|
12
|
+
cache_ok = True
|
|
13
|
+
|
|
14
|
+
@staticmethod
|
|
15
|
+
def _is_dataclass_instance(obj):
|
|
16
|
+
return is_dataclass(obj) and not isinstance(obj, type)
|
|
17
|
+
|
|
18
|
+
def _inner_serialize_dataclass(self, value):
|
|
19
|
+
match value:
|
|
20
|
+
case list():
|
|
21
|
+
return [self._inner_serialize_dataclass(item) for item in value]
|
|
22
|
+
case dict():
|
|
23
|
+
return {k: self._inner_serialize_dataclass(v) for k, v in value.items()}
|
|
24
|
+
if self._is_dataclass_instance(value):
|
|
25
|
+
return asdict(value)
|
|
26
|
+
return value
|
|
27
|
+
|
|
28
|
+
def process_bind_param(self, value, dialect):
|
|
29
|
+
# Serialize recursively without mutating the original object stored on the ORM instance.
|
|
30
|
+
return self._inner_serialize_dataclass(value)
|
|
@@ -16,6 +16,7 @@ from sqlalchemy import (
|
|
|
16
16
|
from sqlalchemy.dialects.postgresql import ARRAY, ENUM, TIMESTAMP
|
|
17
17
|
from sqlalchemy.orm import Mapped, mapped_column, relationship, validates
|
|
18
18
|
|
|
19
|
+
from welearn_database.data.details_dict import DetailsDict
|
|
19
20
|
from welearn_database.data.enumeration import (
|
|
20
21
|
ContextType,
|
|
21
22
|
Counter,
|
|
@@ -44,7 +45,7 @@ class WeLearnDocument(Base):
|
|
|
44
45
|
"""
|
|
45
46
|
This class represents a document in the WeLearn system.
|
|
46
47
|
:cvar id: The unique identifier of the document.
|
|
47
|
-
:cvar doi: The unique DOI identifier if it
|
|
48
|
+
:cvar doi: The unique DOI identifier if it exists for this document
|
|
48
49
|
:cvar external_id: ID use by the document provider for identify it (ex: PubMed ID, ArXiv ID, OAI PMH identifier etc.)
|
|
49
50
|
:cvar external_id_type: The type of the external ID, represented as an enumeration
|
|
50
51
|
:cvar url: The URL of the document.
|
|
@@ -83,7 +84,7 @@ class WeLearnDocument(Base):
|
|
|
83
84
|
lang: Mapped[str | None]
|
|
84
85
|
description: Mapped[str | None]
|
|
85
86
|
full_content: Mapped[str | None]
|
|
86
|
-
details: Mapped[dict[str, Any] | None]
|
|
87
|
+
details: Mapped[dict[str, Any] | None] = mapped_column(DetailsDict)
|
|
87
88
|
trace: Mapped[int | None] = mapped_column(types.BIGINT)
|
|
88
89
|
corpus_id: Mapped[UUID] = mapped_column(
|
|
89
90
|
types.Uuid,
|
|
@@ -478,6 +479,65 @@ class ContextDocument(Base):
|
|
|
478
479
|
)
|
|
479
480
|
|
|
480
481
|
|
|
482
|
+
class HistoricalQtyDocumentPerCorpus(Base):
|
|
483
|
+
__tablename__ = "historical_qty_document_per_corpus"
|
|
484
|
+
__table_args__ = {"schema": schema_name}
|
|
485
|
+
|
|
486
|
+
id = mapped_column(
|
|
487
|
+
types.Uuid,
|
|
488
|
+
primary_key=True,
|
|
489
|
+
server_default=GEN_RANDOM_UUID,
|
|
490
|
+
nullable=False,
|
|
491
|
+
)
|
|
492
|
+
source_name: Mapped[str] = mapped_column()
|
|
493
|
+
quantity: Mapped[int]
|
|
494
|
+
created_at: Mapped[datetime] = mapped_column(
|
|
495
|
+
TIMESTAMP(timezone=False),
|
|
496
|
+
nullable=False,
|
|
497
|
+
default=func.localtimestamp(),
|
|
498
|
+
server_default=NOW,
|
|
499
|
+
)
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
class HistoricalQtyDocumentInQdrantPerCorpus(Base):
|
|
503
|
+
__tablename__ = "historical_qty_document_in_qdrant_per_corpus"
|
|
504
|
+
__table_args__ = {"schema": schema_name}
|
|
505
|
+
|
|
506
|
+
id = mapped_column(
|
|
507
|
+
types.Uuid,
|
|
508
|
+
primary_key=True,
|
|
509
|
+
server_default=GEN_RANDOM_UUID,
|
|
510
|
+
nullable=False,
|
|
511
|
+
)
|
|
512
|
+
source_name: Mapped[str] = mapped_column()
|
|
513
|
+
quantity: Mapped[int]
|
|
514
|
+
created_at: Mapped[datetime] = mapped_column(
|
|
515
|
+
TIMESTAMP(timezone=False),
|
|
516
|
+
nullable=False,
|
|
517
|
+
default=func.localtimestamp(),
|
|
518
|
+
server_default=NOW,
|
|
519
|
+
)
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
class HistoricalQtyDocumentInQdrant(Base):
|
|
523
|
+
__tablename__ = "historical_qty_document_in_qdrant"
|
|
524
|
+
__table_args__ = {"schema": schema_name}
|
|
525
|
+
|
|
526
|
+
id = mapped_column(
|
|
527
|
+
types.Uuid,
|
|
528
|
+
primary_key=True,
|
|
529
|
+
server_default=GEN_RANDOM_UUID,
|
|
530
|
+
nullable=False,
|
|
531
|
+
)
|
|
532
|
+
quantity: Mapped[int]
|
|
533
|
+
created_at: Mapped[datetime] = mapped_column(
|
|
534
|
+
TIMESTAMP(timezone=False),
|
|
535
|
+
nullable=False,
|
|
536
|
+
default=func.localtimestamp(),
|
|
537
|
+
server_default=NOW,
|
|
538
|
+
)
|
|
539
|
+
|
|
540
|
+
|
|
481
541
|
# Views
|
|
482
542
|
class QtyDocumentInQdrant(Base):
|
|
483
543
|
__tablename__ = "qty_document_in_qdrant"
|
{welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/data/models/grafana.py
RENAMED
|
@@ -136,3 +136,18 @@ class Session(Base):
|
|
|
136
136
|
created_at: Mapped[datetime] = mapped_column()
|
|
137
137
|
end_at: Mapped[datetime | None] = mapped_column(nullable=True)
|
|
138
138
|
host: Mapped[str | None] = mapped_column(nullable=True)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
class UsedFeaturePerSession(Base):
|
|
142
|
+
__tablename__ = "used_feature_per_session"
|
|
143
|
+
__table_args__ = {"schema": schema_name}
|
|
144
|
+
__read_only__ = True
|
|
145
|
+
|
|
146
|
+
inferred_user_id: Mapped[uuid.UUID] = mapped_column(
|
|
147
|
+
UUID(as_uuid=True), primary_key=True
|
|
148
|
+
)
|
|
149
|
+
session_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True)
|
|
150
|
+
feature_name: Mapped[str] = mapped_column(primary_key=True)
|
|
151
|
+
cnt: Mapped[int] = mapped_column()
|
|
152
|
+
is_feature_used: Mapped[bool] = mapped_column()
|
|
153
|
+
session_created_at: Mapped[datetime] = mapped_column()
|
{welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/data/models/user_related.py
RENAMED
|
@@ -3,12 +3,11 @@ from uuid import UUID
|
|
|
3
3
|
|
|
4
4
|
from sqlalchemy import ForeignKey, func, types
|
|
5
5
|
from sqlalchemy.dialects.postgresql import ENUM, TIMESTAMP
|
|
6
|
-
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
6
|
+
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
7
7
|
|
|
8
|
-
from welearn_database.data.enumeration import DbSchemaEnum, FilterType
|
|
8
|
+
from welearn_database.data.enumeration import DbSchemaEnum, FilterType
|
|
9
9
|
from welearn_database.data.models.document_related import WeLearnDocument
|
|
10
10
|
|
|
11
|
-
from ...exceptions import EarlyEnumerationVerificationError
|
|
12
11
|
from . import Base
|
|
13
12
|
|
|
14
13
|
schema_name = DbSchemaEnum.USER_RELATED.value
|
|
@@ -218,14 +217,7 @@ class InferredUser(Base):
|
|
|
218
217
|
)
|
|
219
218
|
origin_referrer: Mapped[str | None]
|
|
220
219
|
university_title: Mapped[str | None]
|
|
221
|
-
role: Mapped[str
|
|
222
|
-
ENUM(
|
|
223
|
-
*(r.value.lower() for r in UniversityRole),
|
|
224
|
-
name="university_role",
|
|
225
|
-
schema="user_related",
|
|
226
|
-
),
|
|
227
|
-
nullable=True,
|
|
228
|
-
)
|
|
220
|
+
role: Mapped[str | None]
|
|
229
221
|
created_at: Mapped[datetime] = mapped_column(
|
|
230
222
|
TIMESTAMP(timezone=False),
|
|
231
223
|
nullable=False,
|
|
@@ -233,13 +225,6 @@ class InferredUser(Base):
|
|
|
233
225
|
server_default="NOW()",
|
|
234
226
|
)
|
|
235
227
|
|
|
236
|
-
@validates("role")
|
|
237
|
-
def validate_role(self, key, value):
|
|
238
|
-
valid_roles = {r.value.lower() for r in UniversityRole}
|
|
239
|
-
if value not in valid_roles:
|
|
240
|
-
raise EarlyEnumerationVerificationError(f"Invalid role: {value}")
|
|
241
|
-
return value
|
|
242
|
-
|
|
243
228
|
|
|
244
229
|
class EndpointRequest(Base):
|
|
245
230
|
__tablename__ = "endpoint_request"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/alembic/script.py.mako
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/data/models/__init__.py
RENAMED
|
File without changes
|
{welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/data/models/agent_related.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/modules/text_cleaning.py
RENAMED
|
File without changes
|
{welearn_database-1.4.5.dev0 → welearn_database-1.5.1}/welearn_database/regular_expression.py
RENAMED
|
File without changes
|