fix students total

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

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

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

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

Loading…
Cancel
Save