Skip to content

refactor profile selection query #409

@recalcitrantsupplant

Description

@recalcitrantsupplant

Simplify to use python for the sorting, details from:

#397 (comment)

The SPARQL query replaced a complex set of nested ifs that was hard to follow (6 or so deep as per the ORDER BY clauses). Looking at it again I think we can do it without the nested conditionals:

SELECT the available profiles for a class (+ a hardcoded default profile perhaps)
Put the results from 1 in a set of tuples
Do a sort on it in Python, something like:

    return sorted(
        rows,
        key=lambda r: (
            r.req_profile,
            -r.distance,
            r.def_profile,
            r.req_format,
            r.def_format,
        ),
        reverse=True
    )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    🆕 New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions