fix students total

pull/21891/head
ytqh 1 year ago
parent eb79f28b27
commit c49e3f7c2d

@ -54,7 +54,7 @@ class StudentList(Resource):
total:
type: integer
description: Total number of students matching filters
students:
data:
type: array
items:
type: object

@ -23,7 +23,6 @@ detailed_end_user_fields = {
}
end_users_infinite_scroll_pagination_fields = {
"limit": fields.Integer,
"has_more": fields.Boolean,
"total": fields.Integer,
"data": fields.List(fields.Nested(detailed_end_user_fields)),
}

@ -3,3 +3,9 @@ class InfiniteScrollPagination:
self.data = data
self.limit = limit
self.has_more = has_more
class MultiPagePagination:
def __init__(self, data, total):
self.data = data
self.total = total

@ -1,16 +1,14 @@
from typing import Any, Dict, Optional, Tuple
from extensions.ext_database import db
from libs.infinite_scroll_pagination import InfiniteScrollPagination
from libs.infinite_scroll_pagination import MultiPagePagination
from models.model import App, Conversation, EndUser, Message
from sqlalchemy import and_, desc, func
class EndUserService:
@staticmethod
def pagination_by_filters(
app_model: App, filters: Dict[str, Any], offset: int, limit: int
) -> InfiniteScrollPagination:
def pagination_by_filters(app_model: App, filters: Dict[str, Any], offset: int, limit: int) -> MultiPagePagination:
"""
Get a list of end users with filtering and pagination
@ -115,7 +113,7 @@ class EndUserService:
users.append(end_user_dict)
# Format and return results
return InfiniteScrollPagination(data=users, limit=limit, has_more=total_count > offset + limit)
return MultiPagePagination(data=users, total=total_count)
@staticmethod
def load_end_user_by_id(end_user_id: str) -> EndUser:

Loading…
Cancel
Save