diff --git a/src/app/db/migrations/versions/2024-12-11_add_team_name_to_job_post_7f74b429804b.py b/src/app/db/migrations/versions/2024-12-11_add_team_name_to_job_post_7f74b429804b.py new file mode 100644 index 00000000..2d023fb8 --- /dev/null +++ b/src/app/db/migrations/versions/2024-12-11_add_team_name_to_job_post_7f74b429804b.py @@ -0,0 +1,71 @@ +# type: ignore +"""Add team_name to job_post + +Revision ID: 7f74b429804b +Revises: 61c09de3ee8d +Create Date: 2024-12-11 11:18:19.068433+00:00 + +""" +from __future__ import annotations + +import warnings +from typing import TYPE_CHECKING + +import sqlalchemy as sa +from alembic import op +from advanced_alchemy.types import EncryptedString, EncryptedText, GUID, ORA_JSONB, DateTimeUTC +from sqlalchemy import Text # noqa: F401 + +if TYPE_CHECKING: + from collections.abc import Sequence + +__all__ = ["downgrade", "upgrade", "schema_upgrades", "schema_downgrades", "data_upgrades", "data_downgrades"] + +sa.GUID = GUID +sa.DateTimeUTC = DateTimeUTC +sa.ORA_JSONB = ORA_JSONB +sa.EncryptedString = EncryptedString +sa.EncryptedText = EncryptedText + +# revision identifiers, used by Alembic. +revision = '7f74b429804b' +down_revision = '61c09de3ee8d' +branch_labels = None +depends_on = None + + +def upgrade() -> None: + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=UserWarning) + with op.get_context().autocommit_block(): + schema_upgrades() + data_upgrades() + +def downgrade() -> None: + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=UserWarning) + with op.get_context().autocommit_block(): + data_downgrades() + schema_downgrades() + +def schema_upgrades() -> None: + """schema upgrade migrations go here.""" + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('job_post', schema=None) as batch_op: + batch_op.add_column(sa.Column('team_name', sa.String(), nullable=True)) + + # ### end Alembic commands ### + +def schema_downgrades() -> None: + """schema downgrade migrations go here.""" + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('job_post', schema=None) as batch_op: + batch_op.drop_column('team_name') + + # ### end Alembic commands ### + +def data_upgrades() -> None: + """Add any optional data upgrade migrations here!""" + +def data_downgrades() -> None: + """Add any optional data downgrade migrations here!""" diff --git a/src/app/db/models/job_post.py b/src/app/db/models/job_post.py index 49b24a47..8d42d696 100644 --- a/src/app/db/models/job_post.py +++ b/src/app/db/models/job_post.py @@ -30,6 +30,7 @@ class JobPost(UUIDAuditBase): external_id: Mapped[str | None] = mapped_column(nullable=True, default=None) tools: Mapped[list[Tool] | None] = mapped_column(ToolType, nullable=True, default=None) processes: Mapped[list[Process] | None] = mapped_column(ProcessType, nullable=True, default=None) + team_name: Mapped[str | None] = mapped_column(nullable=True) company_id: Mapped[UUID] = mapped_column(ForeignKey("company.id"), nullable=True, index=True) # ----------- # ORM Relationships diff --git a/src/app/domain/jobs/controllers/job_posts.py b/src/app/domain/jobs/controllers/job_posts.py index 31c9bd00..8dd922f8 100644 --- a/src/app/domain/jobs/controllers/job_posts.py +++ b/src/app/domain/jobs/controllers/job_posts.py @@ -155,6 +155,7 @@ async def create_job_post_from_url( processes=[ Process(name=process["name"]) for process in job_details.get("processes", []) if process.get("name") ], + team_name=job_details.get("team_name"), company_id=company_db_obj.id, ) db_obj = await job_posts_service.create(job_post.to_dict()) diff --git a/src/app/domain/jobs/schemas.py b/src/app/domain/jobs/schemas.py index 0b591669..7dbe558c 100644 --- a/src/app/domain/jobs/schemas.py +++ b/src/app/domain/jobs/schemas.py @@ -1,13 +1,12 @@ from __future__ import annotations +from datetime import datetime # noqa: TCH003 from uuid import UUID # noqa: TCH003 -from datetime import datetime import msgspec -from app.db.models.job_post import JobPost -from app.lib.schema import CamelizedBaseStruct, Location, Tool, Process -from app.domain.companies.schemas import Company, CompanyCreate +from app.domain.companies.schemas import Company # noqa: TCH001 +from app.lib.schema import CamelizedBaseStruct, Location, Process, Tool class JobPost(CamelizedBaseStruct): diff --git a/src/app/domain/jobs/utils.py b/src/app/domain/jobs/utils.py index bc5fae48..c287866a 100644 --- a/src/app/domain/jobs/utils.py +++ b/src/app/domain/jobs/utils.py @@ -96,6 +96,7 @@ Only extract the following information directly from the given job post(which is in the form of HTML/JS code) without adding any outside knowledge or assumptions: - Company Name + - Hiring Team Name - Company URL - Company LinkedIn URL - Job title @@ -121,6 +122,7 @@ "linkedin_url": "https://company/linkedin/url", }} title: "Job title", + team_name: "Hiring Team Name", location: {{"country": "country name", "region": "state or provience name", "city": "city name"}}, tools: [ {{"name": "tool name 1", "certainty": "High"}}, {{"name": "tool name 2", "certainty": "Medium"}} ], processes: [{{"name": "process 1"}}, {{"name": "process 2"}}]