Skip to content

Commit 0122494

Browse files
committed
fix(ingest): ignore pre-Web inception dates as website launch dates
P571 is the owner's inception (e.g. a newspaper founded in 1785), so dates before 1991 are skipped for launch_date. Refs #99
1 parent 27f0821 commit 0122494

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

‎app/ingest/wikidata_fill.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"P127": "owners"},
2828
}
2929
DATES = {"release_date", "launch_date"}
30+
WEB_EPOCH = "1991-01-01"
3031
PROPERTIES = {prop for mapping in MAPPINGS.values() for prop in mapping}
3132

3233

@@ -159,6 +160,9 @@ def fill(record: dict[str, Any], category: str, entity: dict[str, Any],
159160
candidates = values(entity, prop)
160161
if field in DATES:
161162
dates = [parsed for v in candidates if (parsed := calendar_date(v))]
163+
if field == "launch_date":
164+
# P571 is the owner's inception; before the Web it can't be a site launch.
165+
dates = [d for d in dates if d >= WEB_EPOCH]
162166
if dates:
163167
updated[field] = min(dates)
164168
elif field == "homepage_url":

‎tests/test_wikidata_fill.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,10 @@ def handler(request):
164164
assert len(cache.fetch(f"Q{i}" for i in range(1, 51))) == 50
165165
assert sizes == [50, 25, 24]
166166
assert len(list(tmp_path.glob("*.json"))) == 50
167+
168+
169+
def test_pre_web_inception_is_not_a_website_launch():
170+
entity = {"id": "Q1", "claims": {"P571": [claim(timestamp(time="+1785-01-01T00:00:00Z"))]}}
171+
assert "launch_date" not in fill({}, "website", entity, {})
172+
entity = {"id": "Q1", "claims": {"P577": [claim(timestamp(time="+1985-11-20T00:00:00Z"))]}}
173+
assert fill({}, "software", entity, {})["release_date"] == "1985-11-20"

0 commit comments

Comments
 (0)