[WIP] Paginate History Store

Trying an approach with v-infinite-scroll in selector modal
This commit is contained in:
Ahmed Awan
2023-06-16 11:07:43 -04:00
committed by Dannon Baker
parent 6616eebe5c
commit b7e980e71b
6 changed files with 176 additions and 79 deletions
@@ -131,6 +131,17 @@ class FastAPIHistories:
trans, serialization_params, filter_query_params, deleted_only=deleted, all_histories=all
)
# THIS IS JUST A DUMMY ROUTE FOR WIP testing
@router.get(
"/api/histories/count",
summary="Returns number of histories for the current user.",
)
def count(
self,
trans: ProvidesHistoryContext = DependsOnTrans,
) -> int:
return self.service.count(trans)
@router.get(
"/api/histories/deleted",
summary="Returns deleted histories for the current user.",
@@ -462,6 +462,23 @@ class HistoriesService(ServiceBase, ConsumesModelStores, ServesExportStores):
]
return rval
# THIS IS JUST A DUMMY FN FOR WIP testing
def count(
self,
trans: ProvidesHistoryContext,
):
"""
Returns number of histories for the current user.
"""
# bail early with current history if user is anonymous
current_user = self.user_manager.current_user(trans)
if self.user_manager.is_anonymous(current_user):
current_history = self.manager.get_current(trans)
if not current_history:
return 0
return 1
return len(current_user.active_histories)
def published(
self,
trans: ProvidesHistoryContext,