|
@ -5,7 +5,7 @@ from typing import Any, Iterator, List, Optional, TypeVar |
|
|
from pyramid.request import Request |
|
|
from pyramid.request import Request |
|
|
from sqlalchemy import Column, func, inspect |
|
|
from sqlalchemy import Column, func, inspect |
|
|
|
|
|
|
|
|
from tildes.lib.id import id36_to_id |
|
|
|
|
|
|
|
|
from tildes.lib.id import id_to_id36, id36_to_id |
|
|
from .model_query import ModelQuery |
|
|
from .model_query import ModelQuery |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -206,17 +206,19 @@ class PaginatedResults: |
|
|
return len(self.results) |
|
|
return len(self.results) |
|
|
|
|
|
|
|
|
@property |
|
|
@property |
|
|
def next_page_after_id(self) -> int: |
|
|
|
|
|
"""Return "after" ID that should be used to fetch the next page.""" |
|
|
|
|
|
|
|
|
def next_page_after_id36(self) -> str: |
|
|
|
|
|
"""Return "after" ID36 that should be used to fetch the next page.""" |
|
|
if not self.has_next_page: |
|
|
if not self.has_next_page: |
|
|
raise AttributeError |
|
|
raise AttributeError |
|
|
|
|
|
|
|
|
return inspect(self.results[-1]).identity[0] |
|
|
|
|
|
|
|
|
next_id = inspect(self.results[-1]).identity[0] |
|
|
|
|
|
return id_to_id36(next_id) |
|
|
|
|
|
|
|
|
@property |
|
|
@property |
|
|
def prev_page_before_id(self) -> int: |
|
|
|
|
|
"""Return "before" ID that should be used to fetch the prev page.""" |
|
|
|
|
|
|
|
|
def prev_page_before_id36(self) -> str: |
|
|
|
|
|
"""Return "before" ID36 that should be used to fetch the prev page.""" |
|
|
if not self.has_prev_page: |
|
|
if not self.has_prev_page: |
|
|
raise AttributeError |
|
|
raise AttributeError |
|
|
|
|
|
|
|
|
return inspect(self.results[0]).identity[0] |
|
|
|
|
|
|
|
|
prev_id = inspect(self.results[0]).identity[0] |
|
|
|
|
|
return id_to_id36(prev_id) |