-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement external SPARQL queries #791
A new framework for external SPARQL has been implemented. It is only used for the award aspect for now. Jinja macros are defined in base.html for setting up HTML elements from SPARQL querys. HTML element identifiers should be suffix with either -table or -iframe. SPARQL template files should be named aspect_panel.sparql.
- Loading branch information
Showing
10 changed files
with
338 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
SELECT | ||
?number_of_corecipients | ||
?award ?awardLabel ?awardDescription | ||
WITH { | ||
SELECT DISTINCT ?award (COUNT(?recipient) AS ?number_of_corecipients) WHERE { | ||
?recipient wdt:P166 wd:{{ q }} . | ||
?recipient wdt:P166 ?award . | ||
FILTER (?award != wd:{{ q }}) | ||
} | ||
GROUP BY ?award | ||
} AS %result | ||
WHERE { | ||
INCLUDE %result | ||
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,da,de,es,fr,jp,no,ru,sv,zh" . } | ||
} | ||
ORDER BY DESC(?number_of_corecipients) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
SELECT | ||
?count ?gender ?genderLabel | ||
WITH { | ||
SELECT (COUNT(DISTINCT ?recipient) AS ?count) ?gender WHERE { | ||
?recipient wdt:P166 wd:{{ q }} . | ||
?recipient wdt:P21 ?gender . | ||
} | ||
GROUP BY ?gender | ||
} AS %result | ||
WHERE { | ||
INCLUDE %result | ||
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,da,de,ep,fr,jp,nl,no,ru,sv,zh" . } | ||
} | ||
ORDER BY DESC(?count) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#defaultView:ImageGrid | ||
SELECT | ||
?year | ||
?recipient ?recipientLabel | ||
?image | ||
WITH { | ||
SELECT ?recipient ?year (SAMPLE(?image_) AS ?image) WHERE { | ||
?recipient p:P166 ?award_statement . | ||
?award_statement ps:P166 wd:{{ q }} . | ||
OPTIONAL { | ||
?award_statement pq:P585 ?time . | ||
BIND(YEAR(?time) AS ?year) | ||
} | ||
?recipient wdt:P18 ?image_ . | ||
} | ||
GROUP BY ?recipient ?year | ||
} AS %result | ||
WHERE { | ||
INCLUDE %result | ||
SERVICE wikibase:label { bd:serviceParam wikibase:language "en,da,de,es,fr,jp,no,ru,sv,zh" . } | ||
} | ||
ORDER BY DESC(?year) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
SELECT | ||
?year | ||
?recipient ?recipientLabel | ||
?example_work ?example_workLabel | ||
WITH { | ||
SELECT DISTINCT ?recipient ?year (SAMPLE(?work) AS ?example_work) WHERE { | ||
?recipient p:P166 ?award_statement . | ||
?award_statement ps:P166 wd:{{ q }} . | ||
OPTIONAL { | ||
{ ?award_statement pq:P585 ?time } | ||
UNION | ||
{ ?award_statement pq:P580 ?time } | ||
BIND(YEAR(?time) AS ?year) | ||
} | ||
OPTIONAL { ?work wdt:P50 ?recipient . } | ||
} | ||
GROUP BY ?recipient ?year | ||
} AS %result | ||
WHERE { | ||
INCLUDE %result | ||
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,da,de,es,fr,jp,no,ru,sv,zh" . } | ||
} | ||
ORDER BY DESC(?year) |
16 changes: 16 additions & 0 deletions
16
scholia/app/templates/award_locations-of-recipients.sparql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#defaultView:Map | ||
SELECT DISTINCT ?recipient ?recipientLabel ?image ?item ?itemLabel ?geo ?layer | ||
WITH { | ||
SELECT DISTINCT ?recipient ?image ?item ?geo (?property_item_label AS ?layer) WHERE { | ||
?recipient wdt:P166 wd:{{ q }} . | ||
?recipient ?property ?item . | ||
?item wdt:P625 ?geo . | ||
?property_item wikibase:directClaim ?property . | ||
?property_item rdfs:label ?property_item_label . FILTER (LANG(?property_item_label) = 'en') | ||
OPTIONAL { ?item wdt:P18 ?image . } | ||
} | ||
} AS %result | ||
WHERE { | ||
INCLUDE %result | ||
SERVICE wikibase:label { bd:serviceParam wikibase:language "en,da,de,es,fr,jp,nl,no,ru,sv,zh" . } | ||
} |
19 changes: 19 additions & 0 deletions
19
scholia/app/templates/award_recent-publications-by-recipients.sparql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
SELECT ?publication_date ?work ?workLabel ?recipient ?recipientLabel | ||
WITH { | ||
SELECT | ||
(MAX(?publication_datetimes) AS ?publication_datetime) | ||
?work ?recipient | ||
WHERE { | ||
?recipient wdt:P166 wd:{{ q }} . | ||
?work wdt:P50 ?recipient . | ||
OPTIONAL { ?work wdt:P577 ?publication_datetimes . } | ||
} | ||
GROUP BY ?work ?recipient | ||
} AS %result | ||
WHERE { | ||
INCLUDE %result | ||
BIND(xsd:date(?publication_datetime) AS ?publication_date) | ||
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,da,de,es,fr,jp,no,ru,sv,zh" . } | ||
} | ||
ORDER BY DESC(?publication_date) | ||
LIMIT 500 |
17 changes: 17 additions & 0 deletions
17
scholia/app/templates/award_topics-of-works-by-recipients.sparql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#defaultView:BubbleChart | ||
# Count the number of time works by award recipients have set a main topic | ||
SELECT ?count ?topic ?topicLabel | ||
WITH { | ||
SELECT ?topic (COUNT(?work) AS ?count) WHERE { | ||
?recipient wdt:P166 wd:{{ q }} . | ||
?work wdt:P50 ?recipient . | ||
?work wdt:P921 ?topic . | ||
} | ||
GROUP BY ?topic | ||
} AS %result | ||
WHERE { | ||
INCLUDE %result | ||
SERVICE wikibase:label { bd:serviceParam wikibase:language "en,da,de,es,fr,jp,no,ru,sv,zh" . } | ||
} | ||
ORDER BY DESC(?count) | ||
LIMIT 50 |
Oops, something went wrong.