fix contacts

This commit is contained in:
CHIEFSOFT\ameye
2025-08-30 23:26:53 -04:00
parent 477d97e045
commit edd62a8174
2 changed files with 25 additions and 32 deletions
+12 -31
View File
@@ -35,37 +35,17 @@ class ContactService(BaseService):
member_data = Members.get_member_by_uid(uid) member_data = Members.get_member_by_uid(uid)
member_id = member_data.id member_id = member_data.id
contacts_product_list = Products.get_contact_supported_product_list(member_id)
category_data = []
for t in contacts_product_list:
category_data.append({
'cid': t.product_id,
'category_uid': t.uid,
'description': t.name,
})
cat_list = ['A000002', 'A000004', 'A000001', 'A000003'] cat_list = ['A000002', 'A000004', 'A000001', 'A000003']
category_data = [
{
"cid": "1",
"description": "category 01"
},
{
"cid": "2",
"description": "category 02"
},
{
"cid": "3",
"description": "category 03"
},
{
"cid": "4",
"description": "category 04"
}
]
# SUPPORTED_CATEGORY = "SELECT name AS title,product_id from products WHERE product_id IN ('A000002','A000004','A000001','A000003')"
# with connection:
# with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor:
# cursor.execute(SUPPORTED_CATEGORY)
# select_Res = cursor.fetchall()
#
# print(select_Res)
# contacts_category = json.dumps([dict(ix) for ix in select_Res])
# print(contacts_category)
# array_cat = json.loads(contacts_category)
dList = [] dList = []
sample_range = random.randint(20, 60) sample_range = random.randint(20, 60)
@@ -83,7 +63,7 @@ class ContactService(BaseService):
response_data = { response_data = {
"last_update": datetime.datetime.utcnow(), "last_update": datetime.datetime.utcnow(),
"member_id":member_id, "member_id": member_id,
"category": category_data, "category": category_data,
"contacts": dList "contacts": dList
} }
@@ -106,8 +86,9 @@ class ContactService(BaseService):
db.session.rollback() db.session.rollback()
return ResponseHelper.internal_server_error() return ResponseHelper.internal_server_error()
def dummy_message(): def dummy_message():
dmm = "Dmummy Message" + str(random.randint(100, 400)) dmm = "Dmummy Message" + str(random.randint(100, 400))
mss = f""" mss = f"""
{dmm}I truly believe Augustines words are true and if you look at history you know it is true. There are many people in the world with amazing talents who realize only a small percentage of their potential. We all know people who live this truth. {dmm}I truly believe Augustines words are true and if you look at history you know it is true. There are many people in the world with amazing talents who realize only a small percentage of their potential. We all know people who live this truth.
+12
View File
@@ -68,6 +68,18 @@ class Products(db.Model):
logger.info(json_output) logger.info(json_output)
return json_output return json_output
@classmethod
def get_contact_supported_product_list(cls, member_id):
"""
Return all offers in dictionary format.
"""
product_list = cls.query.all()
if not product_list:
raise ValueError(f"No available Products")
return product_list
@classmethod @classmethod
def get_user_product_list(cls, member_id): def get_user_product_list(cls, member_id):
""" """