From 3f08d6d8c41a5356c0bec18b50fa3ba9c69cce37 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 8 Jun 2024 08:18:15 -0700 Subject: [PATCH 1/4] Use a simpler query for books to show on the landing page --- bookwyrm/templatetags/landing_page_tags.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/bookwyrm/templatetags/landing_page_tags.py b/bookwyrm/templatetags/landing_page_tags.py index ea2512cc7..bc7594fc4 100644 --- a/bookwyrm/templatetags/landing_page_tags.py +++ b/bookwyrm/templatetags/landing_page_tags.py @@ -71,14 +71,8 @@ def get_landing_books(): """list of books for the landing page""" return list( set( - models.Edition.objects.filter( - review__published_date__isnull=False, - review__deleted=False, - review__user__local=True, - review__privacy__in=["public", "unlisted"], - ) - .exclude(cover__exact="") + models.Edition.objects.exclude(cover__exact="") .distinct() - .order_by("-review__published_date")[:6] + .order_by("-updated_date")[:6] ) ) From 8a235bcda17e71e1ab1a1daa2baa5da768d772e1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 10 Jul 2024 22:16:44 +0000 Subject: [PATCH 2/4] Bump django from 4.2.11 to 4.2.14 Bumps [django](https://github.com/django/django) from 4.2.11 to 4.2.14. - [Commits](https://github.com/django/django/compare/4.2.11...4.2.14) --- updated-dependencies: - dependency-name: django dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 96fe3aeba..e62d1a160 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,7 @@ boto3==1.34.74 bw-file-resubmit==0.6.0rc2 celery==5.3.6 colorthief==0.2.1 -Django==4.2.11 +Django==4.2.14 django-celery-beat==2.6.0 django-compressor==4.4 django-csp==3.8 From afd44e109c0f7714ac2a3b2c1b9687e67b862e6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adeodato=20Sim=C3=B3?= Date: Sat, 27 Jul 2024 15:19:04 -0300 Subject: [PATCH 3/4] Add an up-to-date sqlparse to requirements.txt This is used in utils/db.py to format triggers. A migration is needed for minor whitespace fixes between 0.4.4 and 0.5.1. --- bookwyrm/migrations/0207_sqlparse_update.py | 51 +++++++++++++++++++++ requirements.txt | 1 + 2 files changed, 52 insertions(+) create mode 100644 bookwyrm/migrations/0207_sqlparse_update.py diff --git a/bookwyrm/migrations/0207_sqlparse_update.py b/bookwyrm/migrations/0207_sqlparse_update.py new file mode 100644 index 000000000..95c46eba2 --- /dev/null +++ b/bookwyrm/migrations/0207_sqlparse_update.py @@ -0,0 +1,51 @@ +# Generated by Django 4.2.11 on 2024-07-27 18:18 + +from django.db import migrations, models +import pgtrigger.compiler +import pgtrigger.migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookwyrm", "0206_merge_20240415_1537"), + ] + + operations = [ + pgtrigger.migrations.RemoveTrigger( + model_name="author", + name="reset_book_search_vector_on_author_edit", + ), + pgtrigger.migrations.RemoveTrigger( + model_name="book", + name="update_search_vector_on_book_edit", + ), + pgtrigger.migrations.AddTrigger( + model_name="author", + trigger=pgtrigger.compiler.Trigger( + name="reset_book_search_vector_on_author_edit", + sql=pgtrigger.compiler.UpsertTriggerSql( + func="WITH updated_books AS (SELECT book_id FROM bookwyrm_book_authors WHERE author_id = new.id) UPDATE bookwyrm_book SET search_vector = '' FROM updated_books WHERE id = updated_books.book_id;RETURN NEW;", + hash="4eeb17d1c9c53f543615bcae1234bd0260adefcc", + operation='UPDATE OF "name", "aliases"', + pgid="pgtrigger_reset_book_search_vector_on_author_edit_a50c7", + table="bookwyrm_author", + when="AFTER", + ), + ), + ), + pgtrigger.migrations.AddTrigger( + model_name="book", + trigger=pgtrigger.compiler.Trigger( + name="update_search_vector_on_book_edit", + sql=pgtrigger.compiler.UpsertTriggerSql( + func="WITH author_names AS (SELECT array_to_string(bookwyrm_author.name || bookwyrm_author.aliases, ' ') AS name_and_aliases FROM bookwyrm_author LEFT JOIN bookwyrm_book_authors ON bookwyrm_author.id = bookwyrm_book_authors.author_id WHERE bookwyrm_book_authors.book_id = new.id) SELECT setweight(coalesce(nullif(to_tsvector('english', new.title), ''), to_tsvector('simple', new.title)), 'A') || setweight(to_tsvector('english', coalesce(new.subtitle, '')), 'B') || (SELECT setweight(to_tsvector('simple', coalesce(array_to_string(array_agg(name_and_aliases), ' '), '')), 'C') FROM author_names) || setweight(to_tsvector('english', coalesce(new.series, '')), 'D') INTO new.search_vector;RETURN NEW;", + hash="676d929ce95beff671544b6add09cf9360b6f299", + operation='INSERT OR UPDATE OF "title", "subtitle", "series", "search_vector"', + pgid="pgtrigger_update_search_vector_on_book_edit_bec58", + table="bookwyrm_book", + when="BEFORE", + ), + ), + ), + ] diff --git a/requirements.txt b/requirements.txt index 96fe3aeba..85ba100c5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -37,6 +37,7 @@ redis==5.0.3 requests==2.32.0 responses==0.25.0 s3-tar==0.1.13 +sqlparse==0.5.1 # Indirect dependencies with version constraints for security fixes grpcio>=1.57.0 From 08876512ebee911c89c265a2068f3f13a42c8836 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adeodato=20Sim=C3=B3?= Date: Sat, 27 Jul 2024 14:48:21 -0300 Subject: [PATCH 4/4] Actions: run makemigrations check with increased verbosity --- .github/workflows/python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 01241b467..68e3b7b65 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -48,7 +48,7 @@ jobs: - name: Set up .env run: cp .env.example .env - name: Check migrations up-to-date - run: python ./manage.py makemigrations --check + run: python ./manage.py makemigrations --check -v 3 - name: Run Tests run: pytest -n 3