From fa380b848d33b38602733d33ce5d8136853def4b Mon Sep 17 00:00:00 2001 From: Nox <56934023+noxethiems@users.noreply.github.com> Date: Wed, 6 Dec 2023 01:32:38 -0300 Subject: [PATCH] Feature/profile interest Co-authored-by: Luis Cusihuaman --- .github/workflows/tests.yml | 1 + identity_socializer/db/dao/user_dao.py | 2 ++ .../versions/2023-12-06-01-14_d98bc4f14185.py | 23 +++++++++++++++++++ identity_socializer/db/models/user_model.py | 3 +++ identity_socializer/tests/test_auth.py | 1 + identity_socializer/web/api/auth/schema.py | 4 +++- identity_socializer/web/api/auth/views.py | 1 + identity_socializer/web/api/utils.py | 1 + 8 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 identity_socializer/db/migrations/versions/2023-12-06-01-14_d98bc4f14185.py diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4f0094e..72ba630 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -83,6 +83,7 @@ jobs: IDENTITY_SOCIALIZER_DB_HOST: localhost devflow: runs-on: ubuntu-latest + if: github.ref != 'refs/heads/main' steps: - name: checkout uses: actions/checkout@master diff --git a/identity_socializer/db/dao/user_dao.py b/identity_socializer/db/dao/user_dao.py index 0213b6c..6476afd 100644 --- a/identity_socializer/db/dao/user_dao.py +++ b/identity_socializer/db/dao/user_dao.py @@ -55,6 +55,7 @@ async def update_user_model( bio_msg: Optional[str] = None, profile_photo_id: Optional[str] = None, ubication: Optional[str] = None, + interests: Optional[List[str]] = None, ) -> None: """Update single user to session.""" @@ -69,6 +70,7 @@ async def update_user_model( bio_msg=bio_msg, profile_photo_id=profile_photo_id, ubication=ubication, + interests=interests, ) ) diff --git a/identity_socializer/db/migrations/versions/2023-12-06-01-14_d98bc4f14185.py b/identity_socializer/db/migrations/versions/2023-12-06-01-14_d98bc4f14185.py new file mode 100644 index 0000000..04e7fe6 --- /dev/null +++ b/identity_socializer/db/migrations/versions/2023-12-06-01-14_d98bc4f14185.py @@ -0,0 +1,23 @@ +"""add interests in users + +Revision ID: d98bc4f14185 +Revises: e4141c4c1350 +Create Date: 2023-12-06 01:14:15.002499 + +""" +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision = "d98bc4f14185" +down_revision = "e4141c4c1350" +branch_labels = None +depends_on = None + + +def upgrade() -> None: + op.add_column("users", sa.Column("interests", sa.ARRAY(sa.String()), nullable=True)) + + +def downgrade() -> None: + op.drop_column("users", "interests") diff --git a/identity_socializer/db/models/user_model.py b/identity_socializer/db/models/user_model.py index 6abb156..658274d 100644 --- a/identity_socializer/db/models/user_model.py +++ b/identity_socializer/db/models/user_model.py @@ -1,5 +1,7 @@ import datetime +from typing import List +from sqlalchemy.dialects.postgresql import ARRAY from sqlalchemy.orm import Mapped, mapped_column from sqlalchemy.sql.sqltypes import Boolean, DateTime, String @@ -29,3 +31,4 @@ class UserModel(Base): default=datetime.datetime.utcnow, nullable=False, ) + interests: Mapped[List[str]] = mapped_column(ARRAY(String), nullable=True) diff --git a/identity_socializer/tests/test_auth.py b/identity_socializer/tests/test_auth.py index f7520be..1d55933 100644 --- a/identity_socializer/tests/test_auth.py +++ b/identity_socializer/tests/test_auth.py @@ -71,6 +71,7 @@ async def test_update_user( "bio_msg": "bio_msg_test", "profile_photo_id": "profile_photo_id_test", "ubication": "Argentina", + "interests": ["some interest"], }, ) diff --git a/identity_socializer/web/api/auth/schema.py b/identity_socializer/web/api/auth/schema.py index 626eb76..cc2b1e2 100644 --- a/identity_socializer/web/api/auth/schema.py +++ b/identity_socializer/web/api/auth/schema.py @@ -1,4 +1,4 @@ -from typing import Optional +from typing import List, Optional from pydantic import BaseModel, ConfigDict @@ -14,6 +14,7 @@ class UserModelDTO(BaseModel): bio_msg: Optional[str] profile_photo_id: Optional[str] ubication: Optional[str] + interests: Optional[List[str]] model_config = ConfigDict(from_attributes=True) @@ -49,4 +50,5 @@ class AppUserModel(BaseModel): is_followed_back: Optional[bool] = False blocked: bool = False certified: bool = False + interests: Optional[List[str]] model_config = ConfigDict(from_attributes=True) diff --git a/identity_socializer/web/api/auth/views.py b/identity_socializer/web/api/auth/views.py index 11b2a58..81f2b81 100644 --- a/identity_socializer/web/api/auth/views.py +++ b/identity_socializer/web/api/auth/views.py @@ -45,6 +45,7 @@ async def update_user( bio_msg=user.bio_msg, profile_photo_id=user.profile_photo_id, ubication=user.ubication, + interests=user.interests, ) diff --git a/identity_socializer/web/api/utils.py b/identity_socializer/web/api/utils.py index 7d7ad5c..d5a75db 100644 --- a/identity_socializer/web/api/utils.py +++ b/identity_socializer/web/api/utils.py @@ -46,4 +46,5 @@ async def complete_user( is_followed_back=is_followed_back, blocked=user.blocked, certified=user.certified, + interests=user.interests, )