contact actions

This commit is contained in:
CHIEFSOFT\ameye
2026-05-14 20:00:22 -04:00
parent 25a44dd7a5
commit 570061caef
2 changed files with 48 additions and 13 deletions
+19
View File
@@ -63,6 +63,25 @@ class ProductsContacts(db.Model):
raise ValueError(f"Database integrity error: {err}")
return product_contact_data
@classmethod
def get_all_contacts(cls,member_id, page=1, limit=20):
query = cls.query
logger.info(f"Get all customer back")
query = query.filter(cls.member_id == member_id)
# Order by created_at descending (newest first)
query = query.order_by(cls.added.desc())
# Get total count before pagination
total_count = query.count()
# Apply pagination
offset = (page - 1) * limit
query = query.limit(limit).offset(offset)
return query.all(), total_count
def to_dict(self):