Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3: Drop support for legacy 'page' parameter #998

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading