diff --git a/app/dao/notifications_dao.py b/app/dao/notifications_dao.py index 040af36f7..992ee57b5 100644 --- a/app/dao/notifications_dao.py +++ b/app/dao/notifications_dao.py @@ -298,17 +298,19 @@ def get_notifications_for_service( if client_reference is not None: filters.append(Notification.client_reference == client_reference) - querie = Notification.query.filter(*filters) + querie = select(Notification).wnere(*filters) querie = _filter_query(querie, filter_dict) if personalisation: querie = querie.options(joinedload(Notification.template)) - return querie.order_by(desc(Notification.created_at)).paginate( - page=page, - per_page=page_size, - count=count_pages, - error_out=error_out, - ) + querie = querie.order_by(desc(Notification.created_at)) + + results = db.session.execute(querie).all() + page_size = current_app.config["PAGE_SIZE"] + offset = (page - 1) * page_size + paginated_results = results[offset : offset + page_size] + pagination = Pagination(paginated_results, page, page_size, len(results)) + return pagination def _filter_query(querie, filter_dict=None):