paginated all data
This commit is contained in:
@@ -50,7 +50,7 @@ class Transaction(db.Model):
|
||||
return cls.query.get(transaction_id)
|
||||
|
||||
@classmethod
|
||||
def get_all_transactions(cls, account_id=None, transaction_type=None, channel=None, start_date=None, end_date=None):
|
||||
def get_all_transactions(cls, account_id=None, transaction_type=None, channel=None, start_date=None, end_date=None, page=1, limit=20):
|
||||
"""
|
||||
Get all transactions with optional filtering
|
||||
|
||||
@@ -85,4 +85,11 @@ class Transaction(db.Model):
|
||||
# Order by created_at descending (newest first)
|
||||
query = query.order_by(cls.created_at.desc())
|
||||
|
||||
return query.all()
|
||||
# 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
|
||||
|
||||
Reference in New Issue
Block a user