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

Add ability to sort by dataset name / date / creator username / size #1

Closed
tjelvar-olsson opened this issue Jul 15, 2019 · 2 comments
Closed
Assignees
Labels
enhancement New feature or request

Comments

@tjelvar-olsson
Copy link
Contributor

This will make it easier to find datasets of interest.

It is likely that the natural place this functionality will be somewhere just below the header.

@tjelvar-olsson tjelvar-olsson added the enhancement New feature or request label Jul 15, 2019
@tjelvar-olsson tjelvar-olsson self-assigned this Jul 15, 2019
jotelha added a commit that referenced this issue Nov 8, 2022
…up-webapp/filesize-8.0.7

Bump filesize from 4.2.1 to 8.0.7 in /dtool-lookup-webapp
@jotelha
Copy link
Member

jotelha commented Feb 3, 2023

With pagination implemented on the server side, sorting would have to happen on the server side as well. Maybe implementing a standardized sorting decorator in the same fashion as the flask_smorest.Blueprint.paginate decorator https://flask-smorest.readthedocs.io/en/latest/api_reference.html#flask_smorest.Blueprint.paginate in the server might be a good idea to make a route like https://github.com/jic-dtool/dtool-lookup-server/blob/d7c5fc1c26c5641e00c346f89c086adce46e3d44/dtool_lookup_server/dataset_routes.py#L101-L118 look like this

@bp.route("/search", methods=["POST"])
@bp.arguments(SearchDatasetSchema(partial=True))
@bp.response(200, DatasetSchema(many=True))
@bp.sort()
@bp.paginate()
@jwt_required()
def search_datasets(
    query: SearchDatasetSchema, pagination_parameters: PaginationParameters, sort_parameters: SortParameters
):
    """List datasets the user has access to matching the query."""
    username = get_jwt_identity()
    try:
        datasets = search_datasets_by_user(username, query, sort_parameters) 
        # better delegate sorting to DB here ...
    except AuthenticationError:
        abort(401)
    # ... or apply sorting post-query here 
    pagination_parameters.item_count = len(datasets)
    return jsonify(
        datasets[pagination_parameters.first_item : pagination_parameters.last_item + 1]
    )

with sort_parameters providing a list of (key, direction) pairs, like for https://pymongo.readthedocs.io/en/stable/api/pymongo/cursor.html#pymongo.cursor.Cursor.sort .

@jotelha
Copy link
Member

jotelha commented Jul 5, 2024

Addressed within #30

@jotelha jotelha closed this as completed Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants