Action call
This commit is contained in:
+50
-38
@@ -41,48 +41,60 @@ class AccountService(BaseService):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def process_action_request(data):
|
def process_action_request(data):
|
||||||
|
|
||||||
member_actions = MembersActions.get_recent_member_actions(data)
|
try:
|
||||||
member_actions_data = []
|
with db.session.begin():
|
||||||
|
|
||||||
for t in member_actions:
|
validated_data = AccountService.validate_data(data, UserSchema())
|
||||||
product_data.append({
|
user_token = validated_data.get('token')
|
||||||
'id': t.id,
|
uid = str(validated_data.get('uid'))
|
||||||
'uid': t.uid,
|
|
||||||
'product_id': t.product_id,
|
|
||||||
'name': t.name,
|
|
||||||
'description': t.description,
|
|
||||||
'status': t.status,
|
|
||||||
'added': t.added,
|
|
||||||
'updated': t.updated,
|
|
||||||
'banner': t.banner
|
|
||||||
})
|
|
||||||
|
|
||||||
action_data = {
|
member_actions = MembersActions.get_recent_member_actions(1)
|
||||||
"recent_actions": member_actions_data,
|
member_actions_data = []
|
||||||
"last_update": datetime.datetime.utcnow(),
|
|
||||||
"initial": random.randint(0, 10),
|
for t in member_actions:
|
||||||
"processing": random.randint(0, 10),
|
product_data.append({
|
||||||
"verifying": random.randint(0, 10),
|
'id': t.id,
|
||||||
"completed": random.randint(0, 10),
|
'uid': t.uid,
|
||||||
"actions": member_actions_data
|
'product_id': t.product_id,
|
||||||
}
|
'name': t.name,
|
||||||
|
'description': t.description,
|
||||||
|
'status': t.status,
|
||||||
|
'added': t.added,
|
||||||
|
'updated': t.updated,
|
||||||
|
'banner': t.banner
|
||||||
|
})
|
||||||
|
|
||||||
|
action_data = {
|
||||||
|
"recent_actions": member_actions_data,
|
||||||
|
"last_update": datetime.datetime.utcnow(),
|
||||||
|
"initial": random.randint(0, 10),
|
||||||
|
"processing": random.randint(0, 10),
|
||||||
|
"verifying": random.randint(0, 10),
|
||||||
|
"completed": random.randint(0, 10),
|
||||||
|
"actions": member_actions_data
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info(f"Member Actions Error: {action_data}")
|
||||||
|
|
||||||
|
return ResponseHelper.success(data=action_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()
|
||||||
|
|
||||||
logger.info(f"Member Actions Error: {action_data}")
|
|
||||||
|
|
||||||
# bar_data = {
|
|
||||||
# "last_update": datetime.datetime.utcnow(),
|
|
||||||
# "top_bar": [
|
|
||||||
# {"id": "1", "description": "Contacts", "last_update": "10-10-2010 11:00 AM",
|
|
||||||
# "value": random.randint(0, 10), "data_span": 'Last 2 months'},
|
|
||||||
# {"id": "2", "description": "Site Traffic", "last_update": "10-10-2010 11:30 AM",
|
|
||||||
# "value": random.randint(0, 10), "data_span": 'Past 12 hours'},
|
|
||||||
# {"id": "3", "description": "Appointments", "last_update": "10-12-2010 11:30 AM",
|
|
||||||
# "value": random.randint(0, 10), "data_span": 'Last 14 days'},
|
|
||||||
# {"id": "4", "description": "Purchases", "last_update": "10-12-2010 11:30 AM",
|
|
||||||
# "value": random.randint(0, 10), "data_span": 'Last 3 months'},
|
|
||||||
# ]
|
|
||||||
# }
|
|
||||||
return ResponseHelper.success(data=action_data)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def process_request(data):
|
def process_request(data):
|
||||||
|
|||||||
Reference in New Issue
Block a user