Skip to content

Commit

Permalink
queries: add comments
Browse files Browse the repository at this point in the history
outside of the built query to avoid sending unnecessary long queries
  • Loading branch information
maxlath committed Nov 9, 2019
1 parent 04397e4 commit befb87f
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 6 deletions.
8 changes: 8 additions & 0 deletions server/data/wikidata/queries/author_works.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ module.exports =
parameters: [ 'qid' ]
query: (params)->
{ qid:authorQid } = params

# P50 author
# P58 screenwriter
# P110 illustrator
# P6338 colorist

# Filter-out instances of edition (Q3331189)

"""
SELECT ?work ?type ?date ?serie WHERE {
?work wdt:P50|wdt:P58|wdt:P110|wdt:P6338 wd:#{authorQid} .
Expand Down
13 changes: 12 additions & 1 deletion server/data/wikidata/queries/editions_reverse_claims.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,22 @@ module.exports =
parameters: [ 'pid', 'qid' ]
query: (params)->
{ pid, qid } = params

# Filter-out entities tagged as both work and edition (Q3331189)

# Work types:
# Q571 book
# Q47461344 written work
# Q7725634 literary work
# Q2831984 comic book album
# Q1004 comic
# Q1760610 comic book
# Q8274 manga

"""
SELECT DISTINCT ?item WHERE {
?item wdt:#{pid} wd:#{qid} .
?item wdt:P31 wd:Q3331189 .
# Filter-out entities tagged as both work and edition
FILTER NOT EXISTS {
VALUES (?work_type) { (wd:Q571) (wd:Q47461344) (wd:Q7725634) (wd:Q2831984) (wd:Q1004) (wd:Q1760610) (wd:Q8274) } .
?item wdt:P31 ?work_type
Expand Down
14 changes: 12 additions & 2 deletions server/data/wikidata/queries/humans_reverse_claims.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@ module.exports =
parameters: [ 'pid', 'qid' ]
query: (params)->
{ pid, qid } = params

# Keep only humans that are known for at least one work

# Work types:
# Q571 book
# Q47461344 written work
# Q7725634 literary work
# Q2831984 comic book album
# Q1004 comic
# Q1760610 comic book
# Q8274 manga

"""
SELECT DISTINCT ?item WHERE {
?item wdt:#{pid} wd:#{qid} .
?item wdt:P31 wd:Q5 .
# Keep only humans that are known for at least one work
?work wdt:P50 ?item .
VALUES (?work_type) { (wd:Q571) (wd:Q47461344) (wd:Q7725634) (wd:Q2831984) (wd:Q1004) (wd:Q1760610) (wd:Q8274) } .
?work wdt:P31 ?work_type .
Expand Down
16 changes: 13 additions & 3 deletions server/data/wikidata/queries/serie_parts.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,28 @@ module.exports =
query: (params)->
{ qid:serieQid } = params

# Reject circular series/parts relations
# Reject parts that have an associated work (duck-typing editions)
# Reject parts that are instance of editions (Q3331189)

# Work types:
# Q571 book
# Q47461344 written work
# Q7725634 literary work
# Q2831984 comic book album
# Q1004 comic
# Q1760610 comic book
# Q8274 manga

"""
SELECT ?part ?date ?ordinal (COUNT(?subpart) AS ?subparts) ?superpart WHERE {
?part p:P179|p:P361 ?serie_statement .
?serie_statement ps:P179|ps:P361 wd:#{serieQid} .
# Reject circular series/parts relations
FILTER NOT EXISTS { wd:#{serieQid} wdt:P179|wdt:P361 ?part }
# Reject parts that have an associated work (duck-typing editions)
FILTER NOT EXISTS { ?part wdt:P629 ?work }
# Reject parts that are instance of editions
FILTER NOT EXISTS {
?part wdt:P31 wd:Q3331189
# but recover parts that are also instances of work
Expand Down
10 changes: 10 additions & 0 deletions server/data/wikidata/queries/works_reverse_claims.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ module.exports =
parameters: [ 'pid', 'qid' ]
query: (params)->
{ pid, qid } = params

# Work types:
# Q571 book
# Q47461344 written work
# Q7725634 literary work
# Q2831984 comic book album
# Q1004 comic
# Q1760610 comic book
# Q8274 manga

"""
SELECT DISTINCT ?item WHERE {
?item wdt:#{pid} wd:#{qid} .
Expand Down

0 comments on commit befb87f

Please sign in to comment.