Skip to content

Commit

Permalink
Merge pull request #6445 from devos50/torrent_schema
Browse files Browse the repository at this point in the history
Fixed Marshmallow REST schemas
  • Loading branch information
ichorid authored Oct 12, 2021
2 parents 7ffd8ae + cc64b41 commit 0ac1cff
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from tribler_core.components.libtorrent.torrentdef import TorrentDef
from tribler_core.components.metadata_store.db.orm_bindings.channel_node import DIRTY_STATUSES, NEW
from tribler_core.components.metadata_store.restapi.metadata_endpoint_base import MetadataEndpointBase
from tribler_core.components.metadata_store.restapi.metadata_schema import ChannelSchema
from tribler_core.components.metadata_store.restapi.metadata_schema import ChannelSchema, MetadataSchema, TorrentSchema
from tribler_core.components.metadata_store.db.serialization import CHANNEL_TORRENT, REGULAR_TORRENT
from tribler_core.components.metadata_store.utils import NoChannelSourcesException, RequestTimeoutException
from tribler_core.restapi.rest_endpoint import HTTP_BAD_REQUEST, HTTP_NOT_FOUND, RESTResponse
Expand Down Expand Up @@ -150,7 +150,7 @@ async def get_channels(self, request):
200: {
'schema': schema(
GetChannelContentsResponse={
'results': [Dict()],
'results': [MetadataSchema],
'first': Integer(),
'last': Integer(),
'sort_by': String(),
Expand Down Expand Up @@ -306,7 +306,7 @@ async def copy_channel(self, request):
responses={
200: {
'description': 'Returns the newly created channel',
'schema': schema(CreateChannelResponse={'results': [Dict()]}),
'schema': schema(CreateChannelResponse={'results': [ChannelSchema]}),
}
},
)
Expand All @@ -324,7 +324,7 @@ async def create_channel(self, request):
responses={
200: {
'description': 'Returns the newly created collection',
'schema': schema(CreateCollectionResponse={'results': [Dict()]}),
'schema': schema(CreateCollectionResponse={'results': [ChannelSchema]}),
}
},
)
Expand Down Expand Up @@ -468,8 +468,8 @@ async def is_channel_dirty(self, request):
responses={
200: {
'schema': schema(
GetChannelContentsResponse={
'results': [Dict()],
GetPopularTorrentsResponse={
'results': [TorrentSchema],
'first': Integer(),
'last': Integer(),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,45 +20,34 @@ class RemoteQueryParameters(MetadataParameters):
channel_pk = String()


class ChannelSchema(Schema):
class MetadataSchema(Schema):
type = Integer()
id = Integer()
origin_id = Integer()
public_key = String()
name = String()
category = String()
status = Integer()
progress = Float(required=False)


class CollectionSchema(MetadataSchema):
torrents = Integer()
state = String()
dirty = Boolean()
infohash = String()
size = Integer()
num_seeders = Integer()
num_leechers = Integer()
last_tracker_check = Integer()
updated = Integer()
subscribed = Boolean()
votes = Float()
progress = Float()
description_flag = Boolean()
thumbnail_flag = Boolean()


class TorrentSchema(Schema):
type = Integer()
id = Integer()
origin_id = Integer()
public_key = String()
name = String()
category = String()
class TorrentSchema(MetadataSchema):
status = Integer()
torrents = Integer()
state = String()
dirty = Boolean()
infohash = String()
size = Integer()
num_seeders = Integer()
num_leechers = Integer()
last_tracker_check = Integer()
updated = Integer()


class ChannelSchema(TorrentSchema, CollectionSchema):
dirty = Boolean()
subscribed = Boolean()
votes = Float()
progress = Float()

0 comments on commit 0ac1cff

Please sign in to comment.