Skip to content

Commit

Permalink
Merge pull request #102 from NatLibFi/EKIR-380-Replace-Literary-Ficti…
Browse files Browse the repository at this point in the history
…on-with-General-Fiction

EKIR-380 Replace Literary with General
  • Loading branch information
natlibfi-kaisa authored Oct 4, 2024
2 parents 9de2d77 + 5aa02f0 commit c85dd3d
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 17 deletions.
4 changes: 2 additions & 2 deletions api/lanes.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def create_lanes_for_large_collection(_db, library, languages, priority=0):
lane_from_genres(
_db,
library,
[genres.Literary_Fiction],
[genres.General_Fiction],
display_name="Contemporary Fiction",
priority=ya_fiction_priority,
**ya_common_args
Expand Down Expand Up @@ -717,7 +717,7 @@ def create_lanes_for_large_collection(_db, library, languages, priority=0):
**children_common_args
)
children_priority += 1
realistic_fiction.add_genre(genres.Literary_Fiction.name)
realistic_fiction.add_genre(genres.General_Fiction.name)
children.sublanes.append(realistic_fiction)

children_graphic_novels, ignore = create(
Expand Down
2 changes: 1 addition & 1 deletion core/classifier/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ def target_age_match(cls, query):
],
),
"Humorous Fiction",
"Literary Fiction",
"General Fiction",
"LGBTQ Fiction",
dict(
name="Mystery",
Expand Down
2 changes: 1 addition & 1 deletion core/classifier/bisac.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ class BISACClassifier(Classifier):
m(Historical_Fiction, anything, "Historical"),
m(Humorous_Fiction, fiction, "Humorous"),
m(Humorous_Fiction, fiction, "Satire"),
m(Literary_Fiction, fiction, "Literary"),
m(General_Fiction, fiction, "Literary"),
m(LGBTQ_Fiction, fiction, "Gay"),
m(LGBTQ_Fiction, fiction, "Lesbian"),
m(LGBTQ_Fiction, fiction, "Gay & Lesbian"),
Expand Down
2 changes: 1 addition & 1 deletion core/classifier/keyword.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ class KeywordBasedClassifier(AgeOrGradeClassifier):
Literary_Criticism: match_kw(
"criticism, interpretation",
),
Literary_Fiction: match_kw(
General_Fiction: match_kw(
"literary",
"literary fiction",
"general fiction",
Expand Down
2 changes: 1 addition & 1 deletion tests/api/finland/test_loan_excel_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"sort_author": "Eliot, George",
"publisher": "Standard Ebooks",
"language": "eng",
"genres": ["Literary Fiction"],
"genres": ["General Fiction"],
"contributors": ["Eliot, George (Author)", "Fake contributor (Author)"],
"location": None,
"library_name": "Open Access Library",
Expand Down
2 changes: 2 additions & 0 deletions tests/core/classifiers/test_keyword.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,5 @@ def test_improvements(self):
assert None == Keyword.genre(None, "Fiction/Urban")

assert classifier.Folklore == Keyword.genre(None, "fables")

assert classifier.General_Fiction == Keyword.genre(None, "literary fiction")
22 changes: 11 additions & 11 deletions tests/core/test_external_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -3290,7 +3290,7 @@ class FilterFixture:
"""A fixture preconfigured with data for testing filters."""

transaction: DatabaseTransactionFixture
literary_fiction: Genre
general_fiction: Genre
fantasy: Genre
horror: Genre
best_sellers: CustomList
Expand All @@ -3302,7 +3302,7 @@ def create(cls, transaction: DatabaseTransactionFixture) -> "FilterFixture":
data.transaction = transaction
session = transaction.session
# Look up three Genre objects which can be used to make filters.
data.literary_fiction, ignore = Genre.lookup(session, "Literary Fiction")
data.general_fiction, ignore = Genre.lookup(session, "General Fiction")
data.fantasy, ignore = Genre.lookup(session, "Fantasy")
data.horror, ignore = Genre.lookup(session, "Horror")

Expand Down Expand Up @@ -3407,17 +3407,17 @@ def test_constructor(self, filter_fixture: FilterFixture):
assert [] == Filter(genre_restriction_sets=[]).genre_restriction_sets
assert [] == Filter(genre_restriction_sets=None).genre_restriction_sets

# Restrict to books that are literary fiction AND (horror OR
# Restrict to books that are general fiction AND (horror OR
# fantasy).
restricted = Filter(
genre_restriction_sets=[
[data.horror, data.fantasy],
[data.literary_fiction],
[data.general_fiction],
]
)
assert [
[data.horror.id, data.fantasy.id],
[data.literary_fiction.id],
[data.general_fiction.id],
] == restricted.genre_restriction_sets

# This is a restriction: 'only books that have no genre'
Expand Down Expand Up @@ -3516,7 +3516,7 @@ def test_from_worklist(

# This lane inherits most of its configuration from its parent.
inherits = transaction.lane(display_name="Child who inherits", parent=parent)
inherits.genres = [data.literary_fiction]
inherits.genres = [data.general_fiction]
inherits.customlists = [data.staff_picks]

class Mock:
Expand Down Expand Up @@ -3778,10 +3778,10 @@ def test_build(self, filter_fixture: FilterFixture):
# We want books by a specific author.
filter.author = ContributorData(sort_name="Ebrity, Sel")

# We want books that are literary fiction, *and* either
# We want books that are general fiction, *and* either
# fantasy or horror.
filter.genre_restriction_sets = [
[data.literary_fiction],
[data.general_fiction],
[data.fantasy, data.horror],
]

Expand Down Expand Up @@ -3852,13 +3852,13 @@ def test_build(self, filter_fixture: FilterFixture):
assert filter.author_filter == contributor_filter

# The genre restrictions are also expressed as nested filters.
literary_fiction_filter, fantasy_or_horror_filter = nested.pop("genres")
general_fiction_filter, fantasy_or_horror_filter = nested.pop("genres")

# There are two different restrictions on genre, because
# genre_restriction_sets was set to two lists of genres.
assert {
"terms": {"genres.term": [data.literary_fiction.id]}
} == literary_fiction_filter.to_dict()
"terms": {"genres.term": [data.general_fiction.id]}
} == general_fiction_filter.to_dict()
assert {
"terms": {"genres.term": [data.fantasy.id, data.horror.id]}
} == fantasy_or_horror_filter.to_dict()
Expand Down

0 comments on commit c85dd3d

Please sign in to comment.