-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
39 lines (34 loc) · 1.46 KB
/
models.py
File metadata and controls
39 lines (34 loc) · 1.46 KB
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
from datetime import datetime
from database import db
class Job(db.Model):
"""Job model for storing job listings"""
__tablename__ = 'jobs'
id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.String(200), nullable=False, index=True)
company = db.Column(db.String(200), nullable=False, index=True)
location = db.Column(db.String(200), nullable=False, index=True)
description = db.Column(db.Text)
salary = db.Column(db.String(100))
job_type = db.Column(db.String(50), index=True)
experience_level = db.Column(db.String(50), index=True)
posted_date = db.Column(db.DateTime, default=datetime.utcnow, index=True)
application_url = db.Column(db.String(500))
scraped = db.Column(db.Boolean, default=False, index=True)
def to_dict(self):
"""Convert job object to dictionary"""
return {
'id': self.id,
'title': self.title,
'company': self.company,
'location': self.location,
'description': self.description,
'salary': self.salary,
'job_type': self.job_type,
'experience_level': self.experience_level,
'posted_date': self.posted_date.isoformat() if self.posted_date else None,
'application_url': self.application_url,
'scraped': self.scraped
}
def __repr__(self):
"""String representation"""
return f'<Job {self.title} at {self.company}>'