calendar data
This commit is contained in:
@@ -129,7 +129,7 @@ def myproduct_dash():
|
|||||||
def mycalendar_dash():
|
def mycalendar_dash():
|
||||||
data = request.get_json()
|
data = request.get_json()
|
||||||
logger.info(f"Route Calendar Data ==>>>> {data}")
|
logger.info(f"Route Calendar Data ==>>>> {data}")
|
||||||
response = MyProductsService.process_request(data)
|
response = AccountService.process_calendar(data)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
# Health Check Endpoint
|
# Health Check Endpoint
|
||||||
|
|||||||
@@ -138,3 +138,51 @@ class AccountService(BaseService):
|
|||||||
return ResponseHelper.internal_server_error()
|
return ResponseHelper.internal_server_error()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def process_calendar(data):
|
||||||
|
try:
|
||||||
|
with db.session.begin():
|
||||||
|
|
||||||
|
validated_data = AccountService.validate_data(data, UserSchema())
|
||||||
|
user_token = validated_data.get('token')
|
||||||
|
uid = str(validated_data.get('uid'))
|
||||||
|
|
||||||
|
dList = []
|
||||||
|
sample_range = random.randint(20, 60)
|
||||||
|
for x in range(sample_range):
|
||||||
|
timeMin = random.randint(1440, 2880)
|
||||||
|
calDate = datetime.datetime.utcnow() + datetime.timedelta(minutes=timeMin * random.randint(0, 20))
|
||||||
|
new_l = {"uid": "425611f2-c692-4404-b93d-76ca7a5ce7" + str(x),
|
||||||
|
"title": "Calendar Random Item on " + str(x), "start": calDate,
|
||||||
|
"category": random.randint(1, 4)}
|
||||||
|
dList.append(new_l)
|
||||||
|
|
||||||
|
calendar_data = {
|
||||||
|
"last_update": datetime.datetime.utcnow(),
|
||||||
|
"category": [
|
||||||
|
{"cid": "1", "description": "category 01"},
|
||||||
|
{"cid": "2", "description": "category 02"},
|
||||||
|
{"cid": "3", "description": "category 03"},
|
||||||
|
{"cid": "4", "description": "category 04"},
|
||||||
|
],
|
||||||
|
"list": dList
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseHelper.success(data=calendar_data)
|
||||||
|
|
||||||
|
except ValidationError as err:
|
||||||
|
|
||||||
|
logger.error(f"Validation Error: {getattr(err, 'messages', str(err))}")
|
||||||
|
db.session.rollback()
|
||||||
|
return ResponseHelper.unprocessable_entity(result_description="Validation exception")
|
||||||
|
|
||||||
|
except ValueError as err:
|
||||||
|
logger.error(f"{getattr(err, 'messages', str(err))}")
|
||||||
|
db.session.rollback()
|
||||||
|
return ResponseHelper.error(result_description=str(err))
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"An error occurred: {str(e)}", exc_info=True)
|
||||||
|
db.session.rollback()
|
||||||
|
return ResponseHelper.internal_server_error()
|
||||||
|
|||||||
Reference in New Issue
Block a user