File size: 3,159 Bytes
a101471
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from typing import List
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
from sqlalchemy import ForeignKey, create_engine


ENGINE = create_engine('sqlite:///application_dev.db')

class Base(DeclarativeBase):
    pass

class Employee(Base):
    __tablename__ = 'employees'
    employee_id: Mapped[str] = mapped_column(primary_key = True)
    email_id: Mapped[str] = mapped_column(unique = True,nullable = False)
    first_name: Mapped[str] = mapped_column(nullable = True)
    last_name: Mapped[str] = mapped_column(nullable = True)
    password: Mapped[str]
    department: Mapped[str]
    # jobs_posted: Mapped[list["Job"]] = relationship(back_populates="jobs")

    def __repr__(self):
        return f'Employee({self.employee_id!r},{self.email_id!r},{self.first_name!r},{self.department!r})'

    @property
    def full_name(self):
        return f'{self.first_name.title()} {self.last_name.title()}'


class Job(Base):
    __tablename__ = 'jobs'
    job_id :Mapped[str] = mapped_column(primary_key = True)
    employee_id :Mapped[str] #= mapped_column(ForeignKey('employees.employee_id'))
    post_name: Mapped[str] = mapped_column(nullable = False)
    description: Mapped[str] = mapped_column(nullable= False)
    responsibilities: Mapped[str]
    min_experience: Mapped[int] = mapped_column(nullable = False)
    max_experience: Mapped[int] = mapped_column(nullable = False)
    primary_skills: Mapped[str] = mapped_column(nullable = False)
    secondary_skills: Mapped[str] = mapped_column(nullable = True)
    vacancies: Mapped[int] = mapped_column(nullable=False)
    # employee: Mapped["Employee"] = relationship(back_populates="employee")
    # users_applied: Mapped[list["User"]] = relationship(back_populates="users")
    created_at: Mapped[str] = mapped_column(nullable=False)
    expires_at: Mapped[str] = mapped_column(nullable = False)

    def __repr__(self):
        return f"Job({self.job_id!r},{self.post_name!r},{self.min_experience},{self.max_experience})"


class User(Base):
    __tablename__ = "users"
    email_id: Mapped[str] = mapped_column(primary_key=True)
    password: Mapped[str] = mapped_column(nullable=False)
    first_name: Mapped[str] = mapped_column(nullable = False)
    last_name: Mapped[str] = mapped_column(nullable = False)

    def __repr__(self):
        return f'User({self.email_id!r},{self.first_name!r},{self.last_name!r})'

    @property
    def full_name(self):
        return f'{self.first_name.title()} {self.last_name.title()}'

      

class JobsApplied(Base):
    __tablename__ = 'jobs_applied'
    email_id: Mapped[str] = mapped_column(primary_key=True)
    job_id: Mapped[str] = mapped_column(ForeignKey('jobs.job_id'))
    rank: Mapped[int] = mapped_column(nullable=False)
    experience: Mapped[int] = mapped_column(nullable=False)
    round_number: Mapped[int] = mapped_column(nullable=False)
    primary_skills: Mapped[int]
    secondary_skills: Mapped[int]
    

    def __repr__(self):
        return f'JobsApplied({self.email_id!r},{self.job_id!r},{self.rank},{self.experience},{self.round_number})'




def __create_tables():
    Base.metadata.create_all(bind = ENGINE)