Join the picker's review-round-1 fixes

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
This commit is contained in:
2026-11-27 15:35:58 +01:00
4 changed files with 58 additions and 23 deletions
+25 -17
View File
@@ -1,6 +1,6 @@
{
"about": {
"made": "2026-11-27T13:56:32+00:00",
"made": "2026-11-27T14:30:14+00:00",
"by": "tools/commons_candidates.py",
"requests": 892,
"layouts": "aerial photos of the circuit dated within the layout's years, at most 40 each",
@@ -16205,7 +16205,7 @@
"licence": "CC BY-SA 2.0 de",
"author": "The original uploader was Spurzem at German Wikipedia.",
"credit": "Photo: The original uploader was Spurzem at German Wikipedia., CC BY-SA 2.0 de, via Wikimedia Commons",
"date": null,
"date": "1969",
"marks": [
"valued"
],
@@ -16217,7 +16217,8 @@
"restrictions": [],
"found": [
"marked"
]
],
"date_from": "category"
},
{
"file": "Jochen Rindt 1969 German GP.jpg",
@@ -16262,7 +16263,7 @@
"licence": "CC BY-SA 2.0 de",
"author": "unknown author",
"credit": "Photo: unknown author, CC BY-SA 2.0 de, via Wikimedia Commons",
"date": null,
"date": "1969",
"marks": [
"valued"
],
@@ -16274,7 +16275,8 @@
"restrictions": [],
"found": [
"marked"
]
],
"date_from": "category"
},
{
"file": "Rodriguez, Pedro - BRM 1968.jpg",
@@ -19533,7 +19535,7 @@
"licence": "CC0",
"author": "Fotopersbureau de Boer",
"credit": "Photo: Fotopersbureau de Boer, CC0, via Wikimedia Commons",
"date": null,
"date": "1973",
"marks": [],
"width": 3392,
"height": 2248,
@@ -19543,7 +19545,8 @@
"restrictions": [],
"found": [
"Category:1973 Formula One season cars"
]
],
"date_from": "category"
},
{
"file": "Goodwood Festival of Speed 27th June 2014-105 (14644285814).jpg",
@@ -24712,7 +24715,7 @@
"licence": "CC BY-SA 4.0",
"author": "Matthias v.d. Elbe",
"credit": "Photo: Matthias v.d. Elbe, CC BY-SA 4.0, via Wikimedia Commons",
"date": null,
"date": "1981",
"marks": [],
"width": 4608,
"height": 3072,
@@ -24722,7 +24725,8 @@
"restrictions": [],
"found": [
"Category:1981 Formula One season cars"
]
],
"date_from": "category"
},
{
"file": "March 811 at Barber 04.jpg",
@@ -30550,7 +30554,7 @@
"licence": "CC BY-SA 3.0",
"author": "The original uploader was Stahlkocher at German Wikipedia.",
"credit": "Photo: The original uploader was Stahlkocher at German Wikipedia., CC BY-SA 3.0, via Wikimedia Commons",
"date": null,
"date": "1989",
"marks": [],
"width": 3438,
"height": 2122,
@@ -30560,7 +30564,8 @@
"restrictions": [],
"found": [
"Category:1989 Formula One season cars"
]
],
"date_from": "category"
}
],
"1990": [
@@ -31495,7 +31500,7 @@
"licence": "CC BY 3.0",
"author": "Matthias v.d. Elbe",
"credit": "Photo: Matthias v.d. Elbe, CC BY 3.0, via Wikimedia Commons",
"date": null,
"date": "1991",
"marks": [],
"width": 4608,
"height": 3072,
@@ -31505,7 +31510,8 @@
"restrictions": [],
"found": [
"Category:1991 Formula One season cars"
]
],
"date_from": "category"
},
{
"file": "DSC 0176 (35635931016).jpg",
@@ -39859,7 +39865,7 @@
"licence": "CC BY 2.0",
"author": "Maurizio Manna",
"credit": "Photo: Maurizio Manna, CC BY 2.0, via Wikimedia Commons",
"date": null,
"date": "2003",
"marks": [],
"width": 2048,
"height": 1536,
@@ -39869,7 +39875,8 @@
"restrictions": [],
"found": [
"Category:2003 Formula One season cars"
]
],
"date_from": "category"
},
{
"file": "DSC01451 (10284182936).jpg",
@@ -43370,7 +43377,7 @@
"licence": "CC BY-SA 4.0",
"author": "Wojtekskalski",
"credit": "Photo: Wojtekskalski, CC BY-SA 4.0, via Wikimedia Commons",
"date": null,
"date": "2008",
"marks": [],
"width": 2576,
"height": 1932,
@@ -43380,7 +43387,8 @@
"restrictions": [],
"found": [
"Category:2008 Formula One season cars"
]
],
"date_from": "category"
},
{
"file": "Ferrari 056 engine (2008) rear Museo Ferrari.jpg",
+10 -4
View File
@@ -279,7 +279,7 @@
const tags = [
...(c.marks || []).map((m) => h('span', { class: 'tag mark', title: 'A Commons quality mark' }, m)),
...(c.restrictions || []).map((r) => h('span', { class: 'tag warn', title: 'A right beside copyright the file names' }, `${r} rights`)),
up ? h('span', { class: 'tag warn', title: 'Smaller than the frame: the service scales it up' }, `scaled up ×${up.toFixed(1)}`) : null,
up ? h('span', { class: 'tag warn', title: 'Smaller than the frame: the service scales it up' }, `scaled up ×${up.toFixed(2)}`) : null,
].filter(Boolean);
const chosen = opts.choose && state.chosen && state.chosen.cand && state.chosen.cand.file === c.file;
const card = h('article', { class: `photo-card${opts.picked ? ' picked' : ''}${chosen ? ' chosen' : ''}` },
@@ -288,7 +288,8 @@
opts.label ? h('div', { class: 'meta' }, h('b', {}, opts.label)) : null,
h('div', { class: 'name' }, c.file),
h('div', { class: 'meta' },
h('b', {}, c.date || 'undated'),
h('b', { title: c.date_from === 'category' ? 'The file gives no date: the season it is filed under' : null },
c.date ? `${c.date}${c.date_from === 'category' ? ' (its season)' : ''}` : 'undated'),
c.width ? ` · ${c.width}×${c.height}` : '',
' · ', c.licence_url ? h('a', { href: c.licence_url, target: '_blank', rel: 'noopener' }, c.licence) : c.licence,
h('br'), c.author),
@@ -387,6 +388,11 @@
const { key, cand, fileName, fileKey, kind } = state.chosen;
const file = state.picks[fileKey];
const existing = file && Object.prototype.hasOwnProperty.call(file, key) ? file[key] : null;
if (kind === 'photo' && !cand.date) {
body.replaceChildren(notice('error', `${cand.file} has no date, and the service refuses an entry without one: run tools/commons_candidates.py again, or choose another.`));
section.hidden = false;
return;
}
const entry = entryFor(existing, kind, cand);
const rule = [' ', h('a', { href: F1.linkWithKept('licences.html') }, 'The licences page'), ' states the rule.'];
const what = kind === 'satellite' ? 'the satellite, not the map' : kind === 'map' ? 'the dark map instead of the satellite' : cand.file;
@@ -453,11 +459,11 @@
// circuit of that country has, checked 2026-11-27) Leaflet scales the deepest tiles up.
const NATIONAL = {
netherlands: { name: 'PDOK’s aerial photo', url: 'https://service.pdok.nl/hwh/luchtfotorgb/wmts/v1_0/Actueel_orthoHR/EPSG:3857/{z}/{x}/{y}.jpeg',
maxNativeZoom: 19, credit: 'Luchtfoto: PDOK / Beeldmateriaal Nederland', licence: 'CC BY 4.0', poster: 'CC BY 4.0' },
maxNativeZoom: 19, credit: 'Luchtfoto: PDOK / Samenwerkingsverband Beeldmateriaal, CC BY 4.0', licence: 'CC BY 4.0', poster: 'CC BY 4.0' },
france: { name: 'IGN’s BD ORTHO 2021–2023', url: 'https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=ORTHOIMAGERY.ORTHOPHOTOS2021-2023&STYLE=normal&TILEMATRIXSET=PM&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=image/jpeg',
maxNativeZoom: 18, credit: '© IGN – BD ORTHO, 2021–2023', licence: 'Licence Ouverte (Etalab) 2.0', poster: 'CC BY 4.0' },
'united-states': { name: 'USGS imagery', url: 'https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/tile/{z}/{y}/{x}',
maxNativeZoom: 16, credit: 'Imagery: USGS', licence: 'public domain', poster: 'CC BY 4.0' },
maxNativeZoom: 16, credit: 'USDA, USGS The National Map: Orthoimagery', licence: 'public domain', poster: 'CC BY 4.0' },
};
const EOX = {
name: 'EOxCloudless 2025',
+11
View File
@@ -77,6 +77,17 @@ class CandidateTest(unittest.TestCase):
self.assertIn("not a photo", why)
class SeasonDateTest(unittest.TestCase):
def test_an_undated_season_photo_takes_its_seasons_year_and_says_so(self):
c = cc.dated_by_season({"file": "Kubica spa.jpg", "date": None}, 2008)
self.assertEqual((c["date"], c["date_from"]), ("2008", "category"))
def test_a_dated_season_photo_keeps_its_own_date(self):
c = cc.dated_by_season({"file": "A.jpg", "date": "2009-05-01"}, 2008)
self.assertEqual(c["date"], "2009-05-01")
self.assertNotIn("date_from", c)
class AerialTest(unittest.TestCase):
def test_a_search_hit_is_aerial_only_when_commons_says_so(self):
def hit(file, cats, found):
+12 -2
View File
@@ -16,7 +16,8 @@ A search hit counts as an aerial photo only when its title or a category says so
word in its description alone matched hundreds of race photos taken from the ground. A candidate holds the fields of a
pick (file, licence, author, credit, date) and what the picker shows beside them (thumb, page, width, height, marks,
restrictions, found). A layout's key is its path under circuits/ without an extension, the key circuits/photos.json
uses; a season's is its year.
uses; a season's is its year. A season candidate whose file gives no date takes the season's year, marked
"date_from": "category".
Commons' rules, kept here: a descriptive User-Agent with the app's address and no person's; one API request at a
time and at most five a second (a request starts at least REQUEST_GAP after the one before); a 429 or a maxlag
@@ -393,6 +394,15 @@ def says_aerial(c: dict) -> bool:
return len(c["found"]) >= 2
def dated_by_season(c: dict, year: int) -> dict:
"""A season candidate is of its season: one with no date of its own takes the season's year, and says so. (A
layout candidate with no date stays out: a circuit's photo may show any of its layouts.)"""
if not c["date"]:
c["date"] = str(year)
c["date_from"] = "category"
return c
def in_years(c: dict, first: int, last: int) -> bool:
return bool(c["date"]) and first <= int(c["date"][:4]) <= last
@@ -447,7 +457,7 @@ def main() -> int:
if not c:
skipped[why] = skipped.get(why, 0) + 1
elif c["file"] not in found:
found[c["file"]] = c
found[c["file"]] = dated_by_season(c, year)
out_seasons[str(year)] = [public(c) for c in sorted(found.values(), key=rank_key)[:SEASON_KEEP]]
print(f"season {year}: {len(found)} licensed photo(s), kept {len(out_seasons[str(year)])} "
f"({fetch.count} requests)", file=sys.stderr)