From e80fc6778690979b032c3013daace14e1dafb0b3 Mon Sep 17 00:00:00 2001 From: Jairo Matos Da Rocha Date: Thu, 3 Oct 2024 19:04:43 -0300 Subject: [PATCH] creat_at --- app/models/payload.py | 2 ++ worker.py | 2 +- workers/gee.py | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/payload.py b/app/models/payload.py index 6b02ce8..3503fc1 100644 --- a/app/models/payload.py +++ b/app/models/payload.py @@ -2,6 +2,7 @@ from typing import List from app.models.oauth2 import UserInfo from pydantic_geojson import FeatureModel, FeatureCollectionModel, PolygonModel +from datetime import datetime class User(BaseModel): name: str @@ -19,6 +20,7 @@ class LapigFeatureCollectionModel(FeatureCollectionModel): class ResultPayload(BaseModel): user: User + created_at: datetime = datetime.now(tz=datetime.timezone.utc) geojson: LapigFeatureCollectionModel request_user: UserInfo class PayloadSaveGeojson(BaseModel): diff --git a/worker.py b/worker.py index fcd7119..36c3936 100644 --- a/worker.py +++ b/worker.py @@ -18,7 +18,7 @@ -@celery.task(name="gee_get_index_pasture",bind=True) +@celery.task(name="Index Pasture GEE",bind=True) def gee_get_index_pasture(self, payload: ResultPayload): result = task_index_pasture(self.request.id, payload) payload_send_mail ={ diff --git a/workers/gee.py b/workers/gee.py index 1767166..3ba4595 100644 --- a/workers/gee.py +++ b/workers/gee.py @@ -2,6 +2,7 @@ from workers.utils.gee2chat import get_chat_pasture, get_chat_pasture_vigor from app.models.payload import ResultPayload from celery.utils.log import get_task_logger +from datetime import datetime from pymongo import MongoClient import ee import geemap @@ -10,6 +11,7 @@ logger = get_task_logger(__name__) def task_index_pasture(task_id: str, payload: ResultPayload): + payload['created_at'] = datetime.now(tz=datetime.timezone.utc) geojson = payload.get('geojson') def gee_credentials(private_key_file): data = json.load(open(private_key_file))