Skip to content

Commit

Permalink
v3: Drop support for legacy 'page' parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
psrok1 committed Dec 11, 2024
1 parent 12d25f3 commit 90380fa
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 27 deletions.
4 changes: 0 additions & 4 deletions mwdb/core/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ class DeprecatedFeature(Enum):
# Use GET /<object_type> instead
# Deprecated in v2.0.0
legacy_search = "legacy_search"
# Legacy ?page parameter in object listing endpoints
# Use "?older_than" instead
# Deprecated in v2.0.0
legacy_page_parameter = "legacy_page_parameter"
# Legacy Metakey API
# Use Attribute API instead
# Deprecated in v2.6.0
Expand Down
6 changes: 0 additions & 6 deletions mwdb/resources/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,6 @@ def get(self):
description: |
Request canceled due to database statement timeout.
"""
if "page" in request.args:
uses_deprecated_api(DeprecatedFeature.legacy_page_parameter)

obj = load_schema(request.args, ObjectListRequestSchema())

pivot_obj = None
Expand All @@ -243,9 +240,6 @@ def get(self):
).order_by(Object.id.desc())
if pivot_obj:
db_query = db_query.filter(Object.id < pivot_obj.id)
# Legacy parameter - to be removed in the future
elif obj["page"] is not None and obj["page"] > 1:
db_query = db_query.offset((obj["page"] - 1) * 10)

objects = db_query.limit(limit).all()

Expand Down
18 changes: 1 addition & 17 deletions mwdb/schema/object.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import json

from marshmallow import (
Schema,
ValidationError,
fields,
post_dump,
pre_load,
validates_schema,
)
from marshmallow import Schema, ValidationError, fields, post_dump, pre_load

from .attribute import AttributeItemRequestSchema, AttributeItemResponseSchema
from .metakey import MetakeyItemRequestSchema
Expand All @@ -16,19 +9,10 @@


class ObjectListRequestSchema(Schema):
page = fields.Int(missing=None) # legacy, to be removed in future
query = fields.Str(missing=None)
older_than = fields.Str(missing=None)
count = fields.Int(missing=10)

@validates_schema
def validate_key(self, data, **kwargs):
if data["page"] is not None and data["older_than"] is not None:
raise ValidationError(
"'page' and 'older_than' can't be used simultaneously. "
"Use 'older_than' for new code."
)


class ObjectCountRequestSchema(Schema):
query = fields.Str(missing=None)
Expand Down

0 comments on commit 90380fa

Please sign in to comment.