Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9340369
paginate.py
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
812 B
Subscribers
None
paginate.py
View Options
"""
Pagination at the GraphQL level
This is a temporary fix and inefficient.
Should eventually be moved to the
backend (storage) level
"""
class
PaginatedList
:
def
__init__
(
self
,
source
):
"""
source can be of any iterable type
"""
self
.
source
=
source
def
get_items
(
self
,
first
,
after
):
"""
Return the 'first' number of
items 'after' the given cursor
"""
return
self
.
source
[
after
:
(
after
+
first
)]
def
get_item_objects
(
self
,
first
,
after
):
"""
Return the 'first' number of
items 'after' the given cursor
with an item cursor
"""
return
[
{
"curosr"
:
first
+
index
,
"node"
:
item
}
for
(
index
,
item
)
in
enumerate
(
self
.
get_items
(
first
,
after
),
1
)
]
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Jul 4 2025, 10:35 AM (4 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3450923
Attached To
rDGQL GraphQL API
Event Timeline
Log In to Comment