Skip to content

Commit

Permalink
Extract team name from job post and save it to job_post.team_name
Browse files Browse the repository at this point in the history
  • Loading branch information
shrir committed Dec 11, 2024
1 parent 779539f commit f041e47
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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!"""
1 change: 1 addition & 0 deletions src/app/db/models/job_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/app/domain/jobs/controllers/job_posts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
7 changes: 3 additions & 4 deletions src/app/domain/jobs/schemas.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
2 changes: 2 additions & 0 deletions src/app/domain/jobs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"}}]
Expand Down

0 comments on commit f041e47

Please sign in to comment.