Show more than just paintings during browse

This commit is contained in:
Edward Betts 2019-11-25 13:46:25 +00:00
parent 036a4be5ed
commit 75257632ba
3 changed files with 22 additions and 5 deletions

18
app.py
View file

@ -47,6 +47,8 @@ find_more_props = {
'P2348': 'time period', 'P2348': 'time period',
'P361': 'part of', 'P361': 'part of',
'P608': 'exhibition history', 'P608': 'exhibition history',
'P180': 'depicts',
'P31': 'instance of',
# possible future props # possible future props
# 'P571': 'inception', # 'P571': 'inception',
@ -55,6 +57,17 @@ find_more_props = {
# 'P123': 'publisher', (only 1) # 'P123': 'publisher', (only 1)
} }
isa_list = [
'Q60520', # sketchbook
'Q93184', # drawing
'Q3305213', # painting
'Q15123870', # lithograph
'Q18761202', # watercolor painting
'Q79218', # triptych
'Q2647254', # study
'Q46686' # reredos
]
@app.teardown_appcontext @app.teardown_appcontext
def shutdown_session(exception=None): def shutdown_session(exception=None):
database.session.remove() database.session.remove()
@ -550,6 +563,7 @@ def get_facets(params):
q = render_template('query/facet.sparql', q = render_template('query/facet.sparql',
params=params, params=params,
isa_list=isa_list,
properties=properties) properties=properties)
bindings = wdqs.run_query_with_cache(q, flat + '_facets') bindings = wdqs.run_query_with_cache(q, flat + '_facets')
@ -575,7 +589,9 @@ def get_artwork_params():
def filter_artwork(params): def filter_artwork(params):
flat = '_'.join(f'{pid}={qid}' for pid, qid in params) flat = '_'.join(f'{pid}={qid}' for pid, qid in params)
q = render_template('query/find_more.sparql', params=params) q = render_template('query/find_more.sparql',
params=params,
isa_list=isa_list)
bindings = wdqs.run_query_with_cache(q, flat) bindings = wdqs.run_query_with_cache(q, flat)
return bindings return bindings

View file

@ -1,11 +1,11 @@
select ?property ?object ?objectLabel (count(*) as ?count) { select ?property ?object ?objectLabel (count(*) as ?count) {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
?item wdt:P31 wd:Q3305213 . VALUES ?isa { {% for isa in isa_list %} wd:{{ isa }} {% endfor %} }
?item wdt:P31 ?isa .
?item wdt:P18 ?image . ?item wdt:P18 ?image .
{% for pid, qid in params %} {% for pid, qid in params %}
?item wdt:{{pid}} wd:{{qid}} . ?item wdt:{{pid}} wd:{{qid}} .
{% endfor %} {% endfor %}
values ?property { {% for pid in properties %} wdt:{{pid}}{% endfor %} } values ?property { {% for pid in properties %} wdt:{{pid}}{% endfor %} }
?item ?property ?object . ?item ?property ?object .
FILTER NOT EXISTS { ?item wdt:P180 ?depicts }
} group by ?property ?propertyLabel ?object ?objectLabel } group by ?property ?propertyLabel ?object ?objectLabel

View file

@ -1,6 +1,8 @@
select ?item ?itemLabel ?image ?artist ?artistLabel ?title ?titleLang ?time ?timeprecision { select ?item ?itemLabel ?image ?artist ?artistLabel ?title ?titleLang ?time ?timeprecision {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
?item wdt:P31 wd:Q3305213 . VALUES ?isa { {% for isa in isa_list %} wd:{{ isa }} {% endfor %} }
?item wdt:P31 ?isa .
{% for pid, qid in params %} {% for pid, qid in params %}
?item wdt:{{pid}} wd:{{qid}} . ?item wdt:{{pid}} wd:{{qid}} .
{% endfor %} {% endfor %}
@ -15,5 +17,4 @@ select ?item ?itemLabel ?image ?artist ?artistLabel ?title ?titleLang ?time ?tim
BIND(LANG(?title) as ?titleLang) BIND(LANG(?title) as ?titleLang)
} }
OPTIONAL { ?item wdt:P170 ?artist } OPTIONAL { ?item wdt:P170 ?artist }
FILTER NOT EXISTS { ?item wdt:P180 ?depicts }
} }