Spaces:
Sleeping
Sleeping
Upload 141 files
Browse files- src/.DS_Store +0 -0
- src/apis/.DS_Store +0 -0
- src/apis/models/BaseModel.py +3 -5
- src/apis/models/__pycache__/BaseModel.cpython-311.pyc +0 -0
- src/apis/routes/__pycache__/post_router.cpython-311.pyc +0 -0
- src/apis/routes/post_router.py +0 -1
- src/utils/.DS_Store +0 -0
- src/utils/__pycache__/mongo.cpython-311.pyc +0 -0
- src/utils/mongo.py +1 -1
src/.DS_Store
CHANGED
|
Binary files a/src/.DS_Store and b/src/.DS_Store differ
|
|
|
src/apis/.DS_Store
CHANGED
|
Binary files a/src/apis/.DS_Store and b/src/apis/.DS_Store differ
|
|
|
src/apis/models/BaseModel.py
CHANGED
|
@@ -1,15 +1,13 @@
|
|
| 1 |
from pydantic import BaseModel, Field
|
| 2 |
from typing import Optional
|
| 3 |
-
|
| 4 |
-
from datetime import datetime, timezone
|
| 5 |
-
|
| 6 |
|
| 7 |
class BaseDocument(BaseModel):
|
| 8 |
created_at: Optional[datetime] = Field(
|
| 9 |
-
default_factory=lambda: datetime.now(
|
| 10 |
)
|
| 11 |
updated_at: Optional[datetime] = Field(
|
| 12 |
-
default_factory=lambda: datetime.now(
|
| 13 |
)
|
| 14 |
expire_at: Optional[datetime] = None
|
| 15 |
|
|
|
|
| 1 |
from pydantic import BaseModel, Field
|
| 2 |
from typing import Optional
|
| 3 |
+
from datetime import datetime
|
|
|
|
|
|
|
| 4 |
|
| 5 |
class BaseDocument(BaseModel):
|
| 6 |
created_at: Optional[datetime] = Field(
|
| 7 |
+
default_factory=lambda: datetime.now().replace(tzinfo=None)
|
| 8 |
)
|
| 9 |
updated_at: Optional[datetime] = Field(
|
| 10 |
+
default_factory=lambda: datetime.now().replace(tzinfo=None)
|
| 11 |
)
|
| 12 |
expire_at: Optional[datetime] = None
|
| 13 |
|
src/apis/models/__pycache__/BaseModel.cpython-311.pyc
CHANGED
|
Binary files a/src/apis/models/__pycache__/BaseModel.cpython-311.pyc and b/src/apis/models/__pycache__/BaseModel.cpython-311.pyc differ
|
|
|
src/apis/routes/__pycache__/post_router.cpython-311.pyc
CHANGED
|
Binary files a/src/apis/routes/__pycache__/post_router.cpython-311.pyc and b/src/apis/routes/__pycache__/post_router.cpython-311.pyc differ
|
|
|
src/apis/routes/post_router.py
CHANGED
|
@@ -62,7 +62,6 @@ async def get_post(post_id: str):
|
|
| 62 |
@router.get("/list", status_code=status.HTTP_200_OK)
|
| 63 |
async def list_all_posts():
|
| 64 |
result = await list_all_posts_controller()
|
| 65 |
-
logger.info(f"RESULT: {result}")
|
| 66 |
if result["status"] == "error":
|
| 67 |
return JSONResponse(content=result, status_code=404)
|
| 68 |
else:
|
|
|
|
| 62 |
@router.get("/list", status_code=status.HTTP_200_OK)
|
| 63 |
async def list_all_posts():
|
| 64 |
result = await list_all_posts_controller()
|
|
|
|
| 65 |
if result["status"] == "error":
|
| 66 |
return JSONResponse(content=result, status_code=404)
|
| 67 |
else:
|
src/utils/.DS_Store
CHANGED
|
Binary files a/src/utils/.DS_Store and b/src/utils/.DS_Store differ
|
|
|
src/utils/__pycache__/mongo.cpython-311.pyc
CHANGED
|
Binary files a/src/utils/__pycache__/mongo.cpython-311.pyc and b/src/utils/__pycache__/mongo.cpython-311.pyc differ
|
|
|
src/utils/mongo.py
CHANGED
|
@@ -56,7 +56,7 @@ class MongoCRUD:
|
|
| 56 |
async def create(self, data: Dict) -> str:
|
| 57 |
"""Create a new document in the collection asynchronously, optionally using a user-specified ID."""
|
| 58 |
await self._ensure_ttl_index()
|
| 59 |
-
now = datetime.now(
|
| 60 |
data["created_at"] = now
|
| 61 |
data["updated_at"] = now
|
| 62 |
if self.ttl_seconds is not None:
|
|
|
|
| 56 |
async def create(self, data: Dict) -> str:
|
| 57 |
"""Create a new document in the collection asynchronously, optionally using a user-specified ID."""
|
| 58 |
await self._ensure_ttl_index()
|
| 59 |
+
now = datetime.now().replace(tzinfo=None)
|
| 60 |
data["created_at"] = now
|
| 61 |
data["updated_at"] = now
|
| 62 |
if self.ttl_seconds is not None:
|