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

Deprioritise Alternates Profile #280

Merged
merged 1 commit into from
Oct 16, 2024
Merged
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
9 changes: 6 additions & 3 deletions prez/services/connegp_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def _compose_select_query(self) -> str:
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX sh: <http://www.w3.org/ns/shacl#>

SELECT ?profile ?title ?class (count(?mid) as ?distance) ?req_profile ?def_profile ?format ?req_format ?def_format
SELECT ?profile ?title ?class (count(?mid) as ?distance) ?req_profile ?def_profile ?format ?req_format ?def_format ?alt_prof

WHERE {{
VALUES ?class {{{" ".join('<' + str(klass) + '>' for klass in self.classes)}}}
Expand All @@ -291,9 +291,10 @@ def _compose_select_query(self) -> str:
altr-ext:hasDefaultProfile ?profile }} AS ?def_profile)
{self._generate_mediatype_if_statements()}
BIND(EXISTS {{ ?profile altr-ext:hasDefaultResourceFormat ?format }} AS ?def_format)
BIND(?profile=<http://www.w3.org/ns/dx/connegp/altr-ext#alt-profile> AS ?alt_prof)
}}
GROUP BY ?class ?profile ?req_profile ?def_profile ?format ?req_format ?def_format ?title
ORDER BY DESC(?req_profile) DESC(?distance) DESC(?def_profile) DESC(?req_format) DESC(?def_format)
GROUP BY ?class ?profile ?req_profile ?def_profile ?format ?req_format ?def_format ?title ?alt_prof
ORDER BY DESC(?req_profile) DESC(?distance) DESC(?def_profile) DESC(?req_format) DESC(?def_format) ASC(?alt_prof)
"""
)
return query
Expand Down Expand Up @@ -336,6 +337,7 @@ async def _do_query(self, query: str) -> tuple[Graph, list]:
item["format"]["value"],
item["req_format"]["value"],
item["def_format"]["value"],
item["alt_prof"]["value"],
]
for item in response[1][0][1]
]
Expand All @@ -350,6 +352,7 @@ async def _do_query(self, query: str) -> tuple[Graph, list]:
"Format",
"Requested Format",
"Default Format",
"Alternate Profile"
]

# Render as a table
Expand Down
Loading