Add missing image report.
This commit is contained in:
parent
92040bcc9f
commit
476db3ca9c
20
app.py
20
app.py
|
@ -855,6 +855,26 @@ def depicts_lookup():
|
|||
|
||||
return jsonify(ret)
|
||||
|
||||
@app.route('/report/missing_image')
|
||||
def missing_image_report():
|
||||
limit = utils.get_int_arg('limit') or 1000
|
||||
q = DepictsItem.query.order_by(DepictsItem.count.desc()).limit(limit)
|
||||
|
||||
qids = [item.qid for item in q]
|
||||
entities = mediawiki.get_entities_dict_with_cache(qids)
|
||||
|
||||
item_list = []
|
||||
|
||||
for depicts in q:
|
||||
entity = entities[depicts.qid]
|
||||
if any(wikibase.first_datavalue(entity, prop) for prop in ('P18', 'P2716')):
|
||||
continue
|
||||
item_list.append(depicts)
|
||||
|
||||
# TODO: call wikidata search to find images that depict item
|
||||
|
||||
return render_template('missing_image.html', item_list=item_list)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.debug = True
|
||||
|
|
25
templates/missing_image.html
Normal file
25
templates/missing_image.html
Normal file
|
@ -0,0 +1,25 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}items used as depicts with no image{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="p-2">
|
||||
<ul>
|
||||
{% for item in item_list %}
|
||||
<li>
|
||||
{{ item.count }}
|
||||
<a href="https://www.wikidata.org/wiki/{{ item.qid }}">{{ item.label }}</a>
|
||||
({{ item.qid }})
|
||||
—
|
||||
<a href="https://www.wikidata.org/w/index.php?sort=relevance&search=haswbstatement%3AP180%3D{{ item.qid }}&title=Special%3ASearch">[depicts search]</a>
|
||||
<a href="https://query.wikidata.org/#%23defaultView%3AImageGrid%0Aselect%20distinct%20%3Fitem%20%3FitemLabel%20%3Fimage%20%7B%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%2Cen%22.%20%7D%0A%20%20%3Fitem%20wdt%3AP180%20wd%3A{{ item.qid }}%20.%0A%20%20%3Fitem%20wdt%3AP18%20%3Fimage%20.%0A%20%20%3Farticle%20schema%3Aabout%20%3Fitem%20.%0A%20%20%3Farticle%20schema%3AinLanguage%20%22en%22%20.%0A%20%20FILTER%20%28SUBSTR%28str%28%3Farticle%29%2C%201%2C%2025%29%20%3D%20%22https%3A%2F%2Fen.wikipedia.org%2F%22%29%0A%7D">[depicts with English article]</a>
|
||||
<a href="https://query.wikidata.org/#%23defaultView%3AImageGrid%0Aselect%20distinct%20%3Fitem%20%3FitemLabel%20%3Fimage%20%7B%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%2Cen%22.%20%7D%0A%20%20%3Fitem%20wdt%3AP180%20wd%3A{{ item.qid }}%20.%0A%20%20%3Fitem%20wdt%3AP18%20%3Fimage%20.%7D">[items used as depicts]</a>
|
||||
{% if item.description %}
|
||||
— {{ item.description }}
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
Loading…
Reference in a new issue