forked from mikechau/titanium_edge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.rb
158 lines (123 loc) · 4.13 KB
/
model.rb
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
require 'rubygems'
require 'data_mapper'
#require 'dm-mysql-adapter'
require 'dm-postgres-adapter'
require 'bcrypt'
# DataMapper.setup(:default, "sqlite://#{Dir.pwd}/db.sqlite")
#DataMapper.setup(:default, "mysql://root:itjobstreet@localhost/seekerdashdb")
DataMapper.setup(:default, "postgres://pmfpekijznvzjw:Hq_zObLrI-YKpLoHpKKy0QLgsH@ec2-54-225-101-164.compute-1.amazonaws.com:5432/d3ev2r7degfpm9")
class User
include DataMapper::Resource
include BCrypt
property :id, Serial, key: true
property :username, String, length: 50
property :firstname, String, length: 50
property :email, String, length:80
property :datejoined, Date
property :age, Integer
property :gender, String, length: 1
property :dob, Date
property :address, String
property :nationality, String, length: 80
property :contactnumber, String, length: 20
property :facebooklink, String, length: 120
property :twitterlink, String, length: 120
property :linkedinlink, String, length: 120
property :githublink, String, length: 120
property :photolink, String, length:200
property :password, BCryptHash
property :singaporepr, Boolean, :default => false #next time get user to choose from a list of countries they have PR status
property :aboutme, String, length: 255
property :insingaporenow, Boolean, :default =>true #if non Singaporean, set this to false
property :activeseeker, Boolean, :default =>true #Seeker to keep this updated.
has n, :matched_jobs
has n, :jobs
has 1, :career_score
has n, :skill_summary
has n, :skills, :through => :skilltags ###n-n###
has n, :skilltags ###n-n###
def authenticate(attempted_password)
if self.password == attempted_password
true
else
false
end
end
end
class Job
include DataMapper::Resource
property :id, Serial, key: true
property :startdate, Date
property :enddate, Date
property :position, String, length:120 # Graduate in what...
property :company, String, length:120 # School
property :responsibilities, String, length:100000 #Grades
property :achievements, String, length: 100000 #Projects
property :user_id, Integer
property :type, String, length:1 #to define if it is a job or education. J or E
property :employerrating, Integer # to rate how good is this company in your opinion
#next time can include an array of skills that are being used in a job
belongs_to :user
end
class MatchedJob
include DataMapper::Resource
property :id, Serial, key: true
property :score, Integer
property :rank, Integer
property :jobfunction, String, length:80
property :joblevel, String, length:80
property :datematched, Date
property :salaryrange, Integer
property :user_id, Integer
belongs_to :user
end
class CareerScore
include DataMapper::Resource
property :id, Serial, key: true
property :careerscore, Integer
property :user_id, Integer
belongs_to :user
end
class Skill ###n-n###
include DataMapper::Resource
property :id, Serial , key: true
property :skill, String, length:100
property :category, String, length:100
has n, :skilltags
has n, :users, :through => :skilltags
end
class Skilltag ###n-n###
include DataMapper::Resource
property :id, Serial , key: true
property :skill_id, Integer
property :user_id, Integer
property :skillscore, Integer
belongs_to :skill, :key => true
belongs_to :user, :key => true
end
class SkillSummary
include DataMapper::Resource
property :id, Serial , key: true
property :user_id, Integer
property :skillrank, Integer
property :skill, String, length:100
property :skillcategory, Integer
belongs_to :user
end
# Tell DataMapper the models are done being defined
DataMapper.finalize
# Update the database to match the properties of User.
DataMapper.auto_upgrade!
# Create a test User
# if User.count == 0
# @user = User.create(username: "tschew")
# @user.password = "tschew"
# @user.firstname = "Vince"
# @user.email = "[email protected]"
# @user.save
# @user = User.create(username: "shaun")
# @user.password = "shaun"
# @user.firstname = "Shaun"
# @user.email = "[email protected]"
# @user.save
# end