Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9345733
visit.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
visit.py
View Options
from
swh.graphql.backends
import
archive
from
swh.graphql.utils
import
utils
from
.base_connection
import
BaseConnection
from
.base_node
import
BaseNode
class
BaseVisitNode
(
BaseNode
):
@property
def
id
(
self
):
# FIXME, use a better id
return
utils
.
b64encode
(
f
"{self.origin}-{str(self.visit)}"
)
@property
def
visitId
(
self
):
# To support the schema naming convention
return
self
.
_node
.
visit
class
OriginVisitNode
(
BaseVisitNode
):
"""
Get the visit directly with an origin URL and a visit ID
"""
def
_get_node_data
(
self
):
return
archive
.
Archive
()
.
get_origin_visit
(
self
.
kwargs
.
get
(
"originUrl"
),
int
(
self
.
kwargs
.
get
(
"visitId"
))
)
class
LatestVisitNode
(
BaseVisitNode
):
"""
Get the latest visit for an origin
self.obj is the origin object here
self.obj.url is the origin URL
"""
def
_get_node_data
(
self
):
return
archive
.
Archive
()
.
get_origin_latest_visit
(
self
.
obj
.
url
)
class
OriginVisitConnection
(
BaseConnection
):
_node_class
=
BaseVisitNode
def
_get_paged_result
(
self
):
"""
Get the visits for the given origin
parent obj (self.obj) is origin here
"""
return
archive
.
Archive
()
.
get_origin_visits
(
self
.
obj
.
url
,
after
=
self
.
_get_after_arg
(),
first
=
self
.
_get_first_arg
()
)
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Fri, Jul 4, 3:29 PM (1 w, 14 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3296148
Attached To
rDGQL GraphQL API
Event Timeline
Log In to Comment