nlbone 0.8.3__py3-none-any.whl → 0.8.5__py3-none-any.whl
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.
- nlbone/adapters/db/postgres/engine.py +4 -2
- nlbone/config/settings.py +2 -0
- nlbone/interfaces/api/pagination/offset_base.py +48 -25
- {nlbone-0.8.3.dist-info → nlbone-0.8.5.dist-info}/METADATA +1 -1
- {nlbone-0.8.3.dist-info → nlbone-0.8.5.dist-info}/RECORD +8 -8
- {nlbone-0.8.3.dist-info → nlbone-0.8.5.dist-info}/WHEEL +0 -0
- {nlbone-0.8.3.dist-info → nlbone-0.8.5.dist-info}/entry_points.txt +0 -0
- {nlbone-0.8.3.dist-info → nlbone-0.8.5.dist-info}/licenses/LICENSE +0 -0
|
@@ -80,8 +80,10 @@ def init_sync_engine(echo: Optional[bool] = None) -> Engine:
|
|
|
80
80
|
SYNC_DSN,
|
|
81
81
|
echo=_settings.DEBUG if echo is None else echo,
|
|
82
82
|
pool_pre_ping=True,
|
|
83
|
-
pool_size=
|
|
84
|
-
max_overflow=
|
|
83
|
+
pool_size=_settings.POSTGRES_POOL_SIZE,
|
|
84
|
+
max_overflow=_settings.POSTGRES_MAX_OVERFLOW,
|
|
85
|
+
pool_timeout=30,
|
|
86
|
+
pool_recycle=1800,
|
|
85
87
|
future=True,
|
|
86
88
|
)
|
|
87
89
|
_sync_session_factory = sessionmaker(
|
nlbone/config/settings.py
CHANGED
|
@@ -70,6 +70,8 @@ class Settings(BaseSettings):
|
|
|
70
70
|
# Database
|
|
71
71
|
# ---------------------------
|
|
72
72
|
POSTGRES_DB_DSN: str = Field(default="postgresql+asyncpg://user:pass@localhost:5432/nlbone")
|
|
73
|
+
POSTGRES_POOL_SIZE: int = Field(default=5)
|
|
74
|
+
POSTGRES_MAX_POOL_SIZE: int = Field(default=10)
|
|
73
75
|
DB_ECHO: bool = Field(default=False)
|
|
74
76
|
DB_POOL_SIZE: int = Field(default=5)
|
|
75
77
|
DB_MAX_OVERFLOW: int = Field(default=10)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import json
|
|
2
|
+
import re
|
|
2
3
|
from math import ceil
|
|
3
|
-
from typing import Any, List, Optional
|
|
4
|
+
from typing import Any, List, Optional, Dict, Union
|
|
4
5
|
|
|
5
6
|
from fastapi import Query
|
|
6
7
|
|
|
@@ -53,36 +54,58 @@ class PaginateRequest:
|
|
|
53
54
|
return result
|
|
54
55
|
|
|
55
56
|
@staticmethod
|
|
56
|
-
def _parse_filters(filters: str) ->
|
|
57
|
+
def _parse_filters(filters: str) -> Dict[str, Any]:
|
|
57
58
|
if not filters:
|
|
58
59
|
return {}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
|
|
61
|
+
stripped_filters = filters.strip()
|
|
62
|
+
|
|
63
|
+
if stripped_filters.startswith(("{", "[")):
|
|
64
|
+
try:
|
|
65
|
+
data = json.loads(stripped_filters)
|
|
63
66
|
return dict(data) if isinstance(data, dict) else {"$": data}
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
except (json.JSONDecodeError, TypeError):
|
|
68
|
+
pass
|
|
69
|
+
|
|
70
|
+
pattern = re.compile(r"(?P<key>[^:,]+):\s*(?P<value>\[.*?\]|[^,]+)")
|
|
71
|
+
filters_dict: Dict[str, Any] = {}
|
|
72
|
+
|
|
73
|
+
for match in pattern.finditer(stripped_filters):
|
|
74
|
+
key = match.group("key").strip().strip("'\"")
|
|
75
|
+
value_raw = match.group("value").strip()
|
|
76
|
+
|
|
77
|
+
filters_dict[key] = PaginateRequest._process_value(value_raw)
|
|
66
78
|
|
|
67
|
-
# CSV key:value pairs
|
|
68
|
-
filters_dict: dict[str, Any] = {}
|
|
69
|
-
for part in filters.split(","):
|
|
70
|
-
part = part.strip()
|
|
71
|
-
if not part or ":" not in part:
|
|
72
|
-
continue
|
|
73
|
-
key, value = part.split(":", 1)
|
|
74
|
-
key = key.strip().strip("'\"")
|
|
75
|
-
value_raw = value.strip().strip("'\"")
|
|
76
|
-
# cast common primitives
|
|
77
|
-
if value_raw.isdigit():
|
|
78
|
-
value_cast: Any = int(value_raw)
|
|
79
|
-
elif value_raw.lower() in {"true", "false"}:
|
|
80
|
-
value_cast = value_raw.lower() == "true"
|
|
81
|
-
else:
|
|
82
|
-
value_cast = value_raw
|
|
83
|
-
filters_dict[key] = value_cast
|
|
84
79
|
return filters_dict
|
|
85
80
|
|
|
81
|
+
@staticmethod
|
|
82
|
+
def _process_value(value: str) -> Any:
|
|
83
|
+
if value.startswith("[") and value.endswith("]"):
|
|
84
|
+
content = value[1:-1]
|
|
85
|
+
if not content.strip():
|
|
86
|
+
return []
|
|
87
|
+
return [PaginateRequest._cast_primitive(item.strip()) for item in content.split(",")]
|
|
88
|
+
|
|
89
|
+
return PaginateRequest._cast_primitive(value)
|
|
90
|
+
|
|
91
|
+
@staticmethod
|
|
92
|
+
def _cast_primitive(value: str) -> Union[int, float, bool, str]:
|
|
93
|
+
clean_value = value.strip("'\"")
|
|
94
|
+
lower_value = clean_value.lower()
|
|
95
|
+
|
|
96
|
+
if lower_value == "true":
|
|
97
|
+
return True
|
|
98
|
+
if lower_value == "false":
|
|
99
|
+
return False
|
|
100
|
+
|
|
101
|
+
if clean_value.isdigit():
|
|
102
|
+
return int(clean_value)
|
|
103
|
+
|
|
104
|
+
try:
|
|
105
|
+
return float(clean_value)
|
|
106
|
+
except ValueError:
|
|
107
|
+
return clean_value
|
|
108
|
+
|
|
86
109
|
def remove_deleted(self, deleted_at_field: str = "deleted_at"):
|
|
87
110
|
self.filters = self.filters | {"deleted_at": None}
|
|
88
111
|
|
|
@@ -16,7 +16,7 @@ nlbone/adapters/db/__init__.py,sha256=0CDSySEk4jJsqmwI0eNuaaLJOJDt8_iSiHBsFdC-L3
|
|
|
16
16
|
nlbone/adapters/db/postgres/__init__.py,sha256=tvCpHOdZbpQ57o7k-plq7L0e1uZe5_Frbh7I-LxW7zM,313
|
|
17
17
|
nlbone/adapters/db/postgres/audit.py,sha256=IuWkPitr70UyQ6-GkAedckp8U-Z4cTgzFbdt_bQv1VQ,4800
|
|
18
18
|
nlbone/adapters/db/postgres/base.py,sha256=I89PsEeR9ADEScG8D5pVSncPrPRBmf-KQQkjajl7Koo,132
|
|
19
|
-
nlbone/adapters/db/postgres/engine.py,sha256=
|
|
19
|
+
nlbone/adapters/db/postgres/engine.py,sha256=BwrIDTV66G6XwVYEwlpWlYUPhVu99zximYSwbpfZqrE,3556
|
|
20
20
|
nlbone/adapters/db/postgres/query_builder.py,sha256=YSlrj7lEGI9RiJ__El5_4j7nCuFogg4pR0oVcBQ9h90,15836
|
|
21
21
|
nlbone/adapters/db/postgres/repository.py,sha256=n01TAzdKd-UbOhirE6KMosuvRdJG2l1cszwVHjTM-Ks,10345
|
|
22
22
|
nlbone/adapters/db/postgres/schema.py,sha256=NlE7Rr8uXypsw4oWkdZhZwcIBHQEPIpoHLxcUo98i6s,1039
|
|
@@ -47,7 +47,7 @@ nlbone/adapters/ticketing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
|
|
|
47
47
|
nlbone/adapters/ticketing/client.py,sha256=J1-eT3qQDAJqrHcVpP1oqWNsRNnJ54dDdBeez-m9wyY,1291
|
|
48
48
|
nlbone/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
49
49
|
nlbone/config/logging.py,sha256=Ot6Ctf7EQZlW8YNB-uBdleqI6wixn5fH0Eo6QRgNkQk,4358
|
|
50
|
-
nlbone/config/settings.py,sha256=
|
|
50
|
+
nlbone/config/settings.py,sha256=yuMBUV1WsPwQrkIFq8sifnvCPUB54ux_i0rVfXxGCRk,4884
|
|
51
51
|
nlbone/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
52
52
|
nlbone/core/application/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
53
53
|
nlbone/core/application/base_worker.py,sha256=5brIToSd-vi6tw0ukhHnUZGZhOLq1SQ-NRRy-kp6D24,1193
|
|
@@ -91,7 +91,7 @@ nlbone/interfaces/api/middleware/access_log.py,sha256=vIkxxxfy2HcjqqKb8XCfGCcSri
|
|
|
91
91
|
nlbone/interfaces/api/middleware/add_request_context.py,sha256=o8mdo-D6fODM9OyHunE5UodkVxsh4F__5tDv8ju8Sxg,1952
|
|
92
92
|
nlbone/interfaces/api/middleware/authentication.py,sha256=Bt6sYu4KtXAyUQnSIp-Z2Z1yKNNtfRy9Y3rOZcYTFhw,3299
|
|
93
93
|
nlbone/interfaces/api/pagination/__init__.py,sha256=pA1uC4rK6eqDI5IkLVxmgO2B6lExnOm8Pje2-hifJZw,431
|
|
94
|
-
nlbone/interfaces/api/pagination/offset_base.py,sha256=
|
|
94
|
+
nlbone/interfaces/api/pagination/offset_base.py,sha256=pdfNgmP99eFC5qCWyY1JgW8hNhOuEGnmrlvQPGArdj8,4709
|
|
95
95
|
nlbone/interfaces/api/schema/__init__.py,sha256=LAqgynfupeqOQ6u0I5ucrcYnojRMZUg9yW8IjKSQTNI,119
|
|
96
96
|
nlbone/interfaces/api/schema/adaptive_schema.py,sha256=bdWBNpP2NfOJ_in4btXn0lrZOK70x-OqfmZ-NpIJdoQ,3347
|
|
97
97
|
nlbone/interfaces/api/schema/base_response_model.py,sha256=EpbxolYLeWgtmXaMbYuL-9FcRQdDtT0d8n_8SOXcoyk,1062
|
|
@@ -116,8 +116,8 @@ nlbone/utils/normalize_mobile.py,sha256=sGH4tV9gX-6eVKozviNWJhm1DN1J28Nj-ERldCYk
|
|
|
116
116
|
nlbone/utils/read_files.py,sha256=mx8dfvtaaARQFRp_U7OOiERg-GT62h09_lpTzIQsVhs,291
|
|
117
117
|
nlbone/utils/redactor.py,sha256=-V4HrHmHwPi3Kez587Ek1uJlgK35qGSrwBOvcbw8Jas,1279
|
|
118
118
|
nlbone/utils/time.py,sha256=DjjyQ9GLsfXoT6NK8RDW2rOlJg3e6sF04Jw6PBUrSvg,1268
|
|
119
|
-
nlbone-0.8.
|
|
120
|
-
nlbone-0.8.
|
|
121
|
-
nlbone-0.8.
|
|
122
|
-
nlbone-0.8.
|
|
123
|
-
nlbone-0.8.
|
|
119
|
+
nlbone-0.8.5.dist-info/METADATA,sha256=c25wL34C2G1SSFPxePgEMlpdXgfGh88966Uc3lLAJIU,2294
|
|
120
|
+
nlbone-0.8.5.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
121
|
+
nlbone-0.8.5.dist-info/entry_points.txt,sha256=CpIL45t5nbhl1dGQPhfIIDfqqak3teK0SxPGBBr7YCk,59
|
|
122
|
+
nlbone-0.8.5.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
123
|
+
nlbone-0.8.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|