events cluster updated with PageInfo
This commit is contained in:
@@ -14,7 +14,11 @@ from ApiLayers.ApiValidations.Custom.token_objects import (
|
||||
)
|
||||
from ApiLayers.ApiValidations.Custom.wrapper_contexts import AuthContext, EventContext
|
||||
from ApiLayers.AllConfigs.Token.config import Auth
|
||||
from Services.PostgresDb.Models.pagination import Pagination, PaginationResult, QueryOptions
|
||||
from Services.PostgresDb.Models.pagination import (
|
||||
Pagination,
|
||||
PaginationResult,
|
||||
QueryOptions,
|
||||
)
|
||||
|
||||
|
||||
TokenDictType = Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
@@ -103,13 +107,19 @@ class ListOptionsBase:
|
||||
|
||||
def init_list_options(self) -> tuple:
|
||||
db_session = self.table.new_session()
|
||||
query_options = QueryOptions(table=self.table, data=self.list_options, model_query=self.model_query)
|
||||
query_options = QueryOptions(
|
||||
table=self.table, data=self.list_options, model_query=self.model_query
|
||||
)
|
||||
return db_session, query_options
|
||||
|
||||
def paginated_result(self, records, response_model: Optional[BaseModel] = None) -> PaginationResult:
|
||||
def paginated_result(
|
||||
self, records, response_model: Optional[BaseModel] = None
|
||||
) -> PaginationResult:
|
||||
pagination = Pagination(data=records)
|
||||
if isinstance(self.list_options, dict):
|
||||
pagination.change(**self.list_options)
|
||||
elif isinstance(self.list_options, BaseModel):
|
||||
pagination.change(**self.list_options.model_dump())
|
||||
return PaginationResult(data=records, pagination=pagination, response_model=response_model)
|
||||
return PaginationResult(
|
||||
data=records, pagination=pagination, response_model=response_model
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user