Skip to content

Commit

Permalink
Count TV seasons as integral children of shows
Browse files Browse the repository at this point in the history
  • Loading branch information
dseomn committed Nov 4, 2023
1 parent a0c4d41 commit 941dbfd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rock_paper_sand/wikidata.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,11 @@ def _is_integral_child(
and parent_classes & _TV_EPISODE_PARENTS
):
return True
if (
wikidata_value.Q_TELEVISION_SERIES_SEASON in child_classes
and wikidata_value.Q_TELEVISION_SERIES in parent_classes
):
return True
if (
wikidata_value.Q_LITERARY_WORK in child_classes
and wikidata_value.Q_LITERARY_WORK in parent_classes
Expand Down
9 changes: 9 additions & 0 deletions rock_paper_sand/wikidata_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,7 @@ def setUp(self) -> None:
wikidata_value.Q_TELEVISION_SERIES_EPISODE,
wikidata_value.Q_TELEVISION_SPECIAL,
},
"Q23": {wikidata_value.Q_TELEVISION_SERIES_SEASON},
"Q31": {wikidata_value.Q_LITERARY_WORK},
"Q3": {wikidata_value.Q_LITERARY_WORK},
},
Expand All @@ -1138,6 +1139,7 @@ def setUp(self) -> None:
children={
wikidata_value.Item("Q21"),
wikidata_value.Item("Q22"),
wikidata_value.Item("Q23"),
},
loose=set(),
),
Expand All @@ -1153,6 +1155,12 @@ def setUp(self) -> None:
children=set(),
loose=set(),
),
"Q23": wikidata.RelatedMedia(
parents=set(),
siblings=set(),
children=set(),
loose=set(),
),
"Q31": wikidata.RelatedMedia(
parents={wikidata_value.Item("Q3")},
siblings=set(),
Expand All @@ -1176,6 +1184,7 @@ def setUp(self) -> None:
media_filter.ResultExtraString(
"related item: https://www.wikidata.org/wiki/Q22"
),
# Q23 is an integral child of Q2.
# Q31 is an integral child of Q3.
media_filter.ResultExtraString(
"related item: https://www.wikidata.org/wiki/Q3"
Expand Down

0 comments on commit 941dbfd

Please sign in to comment.