From 076a5d96651fa7e4407b12727b04f6f21fe0e5f9 Mon Sep 17 00:00:00 2001 From: Tomy Hsieh Date: Sun, 1 Jan 2023 15:32:43 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=F0=9F=8E=9B=20ci:=20Change=20pre-commit=20?= =?UTF-8?q?ci=20base=20branch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .pre-commit-config.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index eb80f5c..e00766c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,7 @@ +ci: + autoupdate_branch: "develop" + autoupdate_commit_msg: "🗄 chore: pre-commit autoupdate" + repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: "v4.4.0" From ff91b78855b3994c9768fbad2eebeba418d1519b Mon Sep 17 00:00:00 2001 From: Tomy Hsieh Date: Sun, 1 Jan 2023 15:33:14 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=9B=A0=20fix:=20SAWarnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tubee/models/action.py | 10 +++++++--- tubee/models/channel.py | 4 +++- tubee/models/subscription.py | 1 + tubee/models/user.py | 7 ++++++- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/tubee/models/action.py b/tubee/models/action.py index 0f79895..950cd08 100644 --- a/tubee/models/action.py +++ b/tubee/models/action.py @@ -42,10 +42,14 @@ class Action(db.Model): # type: ignore ), {}, ) - channel = db.relationship("Channel", back_populates="actions") - subscription = db.relationship("Subscription", back_populates="_actions") + channel = db.relationship( + "Channel", back_populates="actions", overlaps="subscription" + ) + subscription = db.relationship( + "Subscription", back_populates="_actions", overlaps="channel" + ) tag = db.relationship("Tag", back_populates="actions") - user = db.relationship("User", back_populates="actions") + user = db.relationship("User", back_populates="actions", overlaps="subscription") def __init__(self, username: str, params: Union[dict[str, str], None] = None): from .subscription import Subscription diff --git a/tubee/models/channel.py b/tubee/models/channel.py index 26eece9..17df75a 100644 --- a/tubee/models/channel.py +++ b/tubee/models/channel.py @@ -36,7 +36,9 @@ class Channel(db.Model): # type: ignore hub_infos = db.Column(db.JSON, nullable=False, default={}) subscribe_timestamp = db.Column(db.DateTime, default=datetime.utcnow) unsubscribe_timestamp = db.Column(db.DateTime) - actions = db.relationship("Action", back_populates="channel") + actions = db.relationship( + "Action", back_populates="channel", overlaps="subscription" + ) videos = db.relationship( "Video", back_populates="channel", lazy="dynamic", cascade="all, delete-orphan" ) diff --git a/tubee/models/subscription.py b/tubee/models/subscription.py index c8654ec..bd86051 100644 --- a/tubee/models/subscription.py +++ b/tubee/models/subscription.py @@ -31,6 +31,7 @@ class Subscription(db.Model): # type: ignore back_populates="subscription", lazy="dynamic", cascade="all, delete-orphan", + overlaps="actions,channel,user", ) _subscription_tags = db.relationship( "SubscriptionTag", diff --git a/tubee/models/user.py b/tubee/models/user.py index b55fa1b..32ffbd9 100644 --- a/tubee/models/user.py +++ b/tubee/models/user.py @@ -60,7 +60,12 @@ class User(UserMixin, db.Model): # type: ignore tags = db.relationship( "Tag", back_populates="user", lazy="dynamic", cascade="all, delete-orphan" ) - actions = db.relationship("Action", back_populates="user", lazy="dynamic") + actions = db.relationship( + "Action", + back_populates="user", + lazy="dynamic", + overlaps="_actions,subscription", + ) def __init__(self, username, password, admin=False, **kwargs): self.username = username From beb84193f7249a68c284918ff4cc2d232dc46aea Mon Sep 17 00:00:00 2001 From: Tomy Hsieh Date: Sun, 1 Jan 2023 15:33:30 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=F0=9F=97=84=20chore:=20Drop=20old=20email?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 37b32c6..e95363f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ name = "tubee" version = "0.14.0" description = "A Web Application for Monitoring New YouTube Videos" license = "MIT License" -authors = ["Tomy Hsieh "] +authors = ["Tomy Hsieh "] readme = "README.md" homepage = "https://github.com/tomy0000000/Tubee" repository = "https://github.com/tomy0000000/Tubee" From f08f17ad2ecc8d7dc22f05e728b944185d0c7fab Mon Sep 17 00:00:00 2001 From: Tomy Hsieh Date: Sun, 1 Jan 2023 15:34:36 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=F0=9F=97=84=20chore:=20Dev=20setup=20impro?= =?UTF-8?q?vements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Makefile for various task - Disable celery worker auto-reloading - Add VSCode suggest extensions --- .vscode/extensions.json | 9 ++++++++ Makefile | 48 +++++++++++++++++++++++++++++++++++++++++ docker-compose.dev.yml | 6 ------ 3 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 .vscode/extensions.json create mode 100644 Makefile diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..d0970c3 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,9 @@ +{ + "recommendations": [ + "bungcip.better-toml", + "ryanluker.vscode-coverage-gutters", + "whatwedo.twig", + "donjayamanne.jquerysnippets", + "cschleiden.vscode-github-actions" + ] +} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..58ccf01 --- /dev/null +++ b/Makefile @@ -0,0 +1,48 @@ +define USAGE +Tubee, the YouTube subscription dashboard + +Commands: + install Install dependencies for local development + build Build docker images + start Start the application for development + test Run coverage unit tests + shell Enter interactive shell for debug + db_migrate Create a new database migration (Run with make db_migrate MESSAGE="message") + db_upgrade Upgrade the database to the latest migration + uninstall Uninstall environment + reinstall Reinstall environment (when Python version is bumped) + +endef + +export USAGE + +help: + @echo "$$USAGE" + +install: + pyenv install -s $(shell cat .python-version) + poetry env use $(shell echo $(shell pyenv shell $(shell cat .python-version); pyenv which python)) + poetry install + +build: + docker compose --file docker-compose.dev.yml build + +start: + docker compose --file docker-compose.dev.yml up + +test: + poetry run flask test --coverage + +shell: + poetry run flask shell + +db_migrate: + docker compose --file docker-compose.dev.yml exec tubee flask db migrate -m $(MESSAGE) + +db_upgrade: + docker compose --file docker-compose.dev.yml exec tubee flask db upgrade + +uninstall: + poetry env remove --all + +reinstall: uninstall install build diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 015aeb4..a4655c7 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -38,12 +38,6 @@ services: celery: build: . command: - - "watchmedo" - - "auto-restart" - - "--directory=./" - - "--pattern=*.py" - - "--recursive" - - "--" - "celery" - "--app=celery_worker.celery" - "worker" From 0ba398880aac7874da1d306d72ea4c2102f3b8cf Mon Sep 17 00:00:00 2001 From: Tomy Hsieh Date: Sun, 1 Jan 2023 15:35:05 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=F0=9F=8E=9B=20ci:=20Surpress=20deploy=20pr?= =?UTF-8?q?ogress=20bar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 33f2c92..527ca36 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -120,6 +120,6 @@ jobs: docker compose down rm docker-compose.yml wget "https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/docker-compose.yml" - docker compose pull + docker compose pull --quiet docker compose up --detach docker network connect nginx_default tubee_beta_app