Skip to content

Commit

Permalink
Remove index for author.search_vector, which is never used
Browse files Browse the repository at this point in the history
  • Loading branch information
dato committed Nov 25, 2023
1 parent 222c3a6 commit fdca981
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
16 changes: 16 additions & 0 deletions bookwyrm/migrations/0190_book_search_updates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 3.2.20 on 2023-11-24 17:11

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("bookwyrm", "0188_theme_loads"),
]

operations = [
migrations.RemoveIndex(
model_name="author",
name="bookwyrm_au_search__b050a8_gin",
),
]
5 changes: 0 additions & 5 deletions bookwyrm/models/author.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,3 @@ def get_remote_id(self):
return f"https://{DOMAIN}/author/{self.id}"

activity_serializer = activitypub.Author

class Meta:
"""sets up postgres GIN index field"""

indexes = (GinIndex(fields=["search_vector"]),)
13 changes: 7 additions & 6 deletions bookwyrm/tests/test_book_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,21 +156,21 @@ def setUp(self):
def test_search_after_changed_metadata(self):
"""book found after updating metadata"""
self.assertEqual(self.edition, self._search_first("First")) # title
self.assertEqual(self.edition, self._search_first("Good")) # subtitle
self.assertEqual(self.edition, self._search_first("Sequence")) # series
self.assertEqual(self.edition, self._search_first("Good")) # subtitle
self.assertEqual(self.edition, self._search_first("Sequence")) # series

self.edition.title = "Second Title of Work"
self.edition.subtitle = "Fewer Words Is Better"
self.edition.series = "A Wondrous Bunch"
self.edition.save(broadcast=False)

self.assertEqual(self.edition, self._search_first("Second")) # title new
self.assertEqual(self.edition, self._search_first("Second")) # title new
self.assertEqual(self.edition, self._search_first("Fewer")) # subtitle new
self.assertEqual(self.edition, self._search_first("Wondrous")) # series new
self.assertEqual(self.edition, self._search_first("Wondrous")) # series new

self.assertFalse(self._search_first("First")) # title old
self.assertFalse(self._search_first("Good")) # subtitle old
self.assertFalse(self._search_first("Sequence")) # series old
self.assertFalse(self._search_first("Good")) # subtitle old
self.assertFalse(self._search_first("Sequence")) # series old

def test_search_after_author_remove(self):
"""book not found via removed author"""
Expand Down Expand Up @@ -211,6 +211,7 @@ def _search_first(self, query):
"""wrapper around search_title_author"""
return self._search(query, return_first=True)

# pylint: disable-next=no-self-use
def _search(self, query, *, return_first=False):
"""wrapper around search_title_author"""
return book_search.search_title_author(
Expand Down

0 comments on commit fdca981

Please sign in to comment.