Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
VeNJOB
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nguyen Ngoc Nghia
VeNJOB
Commits
8e2dcc16
Commit
8e2dcc16
authored
Dec 02, 2019
by
nnnghia98
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update controllers
parent
5a71084e
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
42 additions
and
21 deletions
+42
-21
app/controllers/cities_controller.rb
+1
-0
app/controllers/industries_controller.rb
+1
-0
app/controllers/jobs_controller.rb
+1
-0
app/models/company.rb
+4
-2
app/models/job.rb
+2
-2
app/views/companies/index.html.erb
+2
-0
app/views/jobs/index.html.erb
+2
-2
db/migrate/20191126083110_create_jobs.rb
+1
-1
db/migrate/20191126083151_create_user_jobs.rb
+2
-2
db/migrate/20191126083216_create_city_jobs.rb
+2
-2
db/migrate/20191126083227_create_industry_jobs.rb
+2
-2
db/migrate/20191202023059_add_company_code_to_company.rb
+5
-0
db/migrate/20191202023440_add_index_to_company_code.rb
+5
-0
db/schema.rb
+10
-8
lib/.~lock.jobss.csv#
+2
-0
No files found.
app/controllers/cities_controller.rb
View file @
8e2dcc16
...
...
@@ -5,5 +5,6 @@ class CitiesController < ApplicationController
def
import
City
.
cities_import
redirect_to
root_path
end
end
app/controllers/industries_controller.rb
View file @
8e2dcc16
...
...
@@ -5,5 +5,6 @@ class IndustriesController < ApplicationController
def
import
Industry
.
industries_import
redirect_to
root_path
end
end
app/controllers/jobs_controller.rb
View file @
8e2dcc16
...
...
@@ -5,5 +5,6 @@ class JobsController < ApplicationController
def
import
Job
.
jobs_import
redirect_to
jobs_index_path
end
end
app/models/company.rb
View file @
8e2dcc16
...
...
@@ -11,12 +11,14 @@ require "activerecord-import"
# require "activerecord -import/active_record/adapters/mysql_adapter"
class
Company
<
ApplicationRecord
has_many
:jobs
,
dependent: :destroy
def
self
.
companies_import
companies
=
[]
columns
=
[
:name
,
:email
,
:address
]
columns
=
[
:name
,
:email
,
:address
,
:company_code
]
CSV
.
foreach
(
Rails
.
root
.
join
(
"lib"
,
"jobss.csv"
),
headers:
true
)
do
|
row
|
companies
<<
{
name:
row
[
"company name"
],
email:
row
[
"contact email"
],
address:
row
[
"company address"
]}
companies
<<
{
name:
row
[
"company name"
],
email:
row
[
"contact email"
],
address:
row
[
"company address"
]
,
company_code:
row
[
"company id"
]
}
end
Company
.
import
columns
,
companies
,
on_duplicate_key_ignore:
true
...
...
app/models/job.rb
View file @
8e2dcc16
...
...
@@ -20,10 +20,10 @@ class Job < ApplicationRecord
def
self
.
jobs_import
jobs
=
[]
columns
=
[
:title
,
:level
,
:salary
,
:description
,
:short_des
,
:requirement
,
:category
]
columns
=
[
:title
,
:level
,
:salary
,
:description
,
:short_des
,
:requirement
,
:category
,
:company_id
]
CSV
.
foreach
(
Rails
.
root
.
join
(
"lib"
,
"jobss.csv"
),
headers:
true
)
do
|
row
|
jobs
<<
{
title:
row
[
"name"
],
level:
row
[
"level"
],
salary:
row
[
"salary"
],
description:
row
[
"description"
],
short_des:
row
[
"ben
i
fit"
],
requirement:
row
[
"requirement"
],
category:
row
[
"type"
]}
jobs
<<
{
title:
row
[
"name"
],
level:
row
[
"level"
],
salary:
row
[
"salary"
],
description:
row
[
"description"
],
short_des:
row
[
"ben
e
fit"
],
requirement:
row
[
"requirement"
],
category:
row
[
"type"
]}
end
Job
.
import
columns
,
jobs
...
...
app/views/companies/index.html.erb
View file @
8e2dcc16
...
...
@@ -6,6 +6,7 @@
<th
scope=
"col"
>
company name
</th>
<th
scope=
"col"
>
contact email
</th>
<th
scope=
"col"
>
company address
</th>
<th
scope=
"col"
>
company code
</th>
</tr>
</thead>
<tbody>
...
...
@@ -14,6 +15,7 @@
<td>
<%=
company
.
name
%>
</td>
<td>
<%=
company
.
email
%>
</td>
<td>
<%=
company
.
address
%>
</td>
<td>
<%=
company
.
company_code
%>
</td>
</tr>
<%
end
%>
</tbody>
...
...
app/views/jobs/index.html.erb
View file @
8e2dcc16
...
...
@@ -2,7 +2,7 @@
<thead>
<tr>
<th
scope=
"col"
>
title
</th>
<th
scope=
"col"
>
level
</th>
<th
scope=
"col"
>
short description
</th>
<th
scope=
"col"
>
salary
</th>
</tr>
</thead>
...
...
@@ -10,7 +10,7 @@
<%
@jobs
.
each
do
|
job
|
%>
<tr>
<td>
<%=
job
.
title
%>
</td>
<td>
<%=
job
.
level
%>
</td>
<td>
<%=
job
.
short_des
%>
</td>
<td>
<%=
job
.
salary
%>
</td>
</tr>
<%
end
%>
...
...
db/migrate/20191126083110_create_jobs.rb
View file @
8e2dcc16
...
...
@@ -11,7 +11,7 @@ class CreateJobs < ActiveRecord::Migration[6.0]
t
.
integer
:category
t
.
datetime
:post_date
t
.
datetime
:expiration_date
t
.
references
:company
,
null:
false
,
foreign_key:
true
t
.
references
:company
,
foreign_key:
true
t
.
timestamps
end
...
...
db/migrate/20191126083151_create_user_jobs.rb
View file @
8e2dcc16
class
CreateUserJobs
<
ActiveRecord
::
Migration
[
6.0
]
def
change
create_table
:user_jobs
do
|
t
|
t
.
references
:user
,
null:
false
,
foreign_key:
true
t
.
references
:job
,
null:
false
,
foreign_key:
true
t
.
references
:user
,
foreign_key:
true
t
.
references
:job
,
foreign_key:
true
t
.
datetime
:applied_at
t
.
datetime
:viewed_at
t
.
datetime
:favorited_at
...
...
db/migrate/20191126083216_create_city_jobs.rb
View file @
8e2dcc16
class
CreateCityJobs
<
ActiveRecord
::
Migration
[
6.0
]
def
change
create_table
:city_jobs
do
|
t
|
t
.
references
:city
,
null:
false
,
foreign_key:
true
t
.
references
:job
,
null:
false
,
foreign_key:
true
t
.
references
:city
,
foreign_key:
true
t
.
references
:job
,
foreign_key:
true
t
.
timestamps
end
...
...
db/migrate/20191126083227_create_industry_jobs.rb
View file @
8e2dcc16
class
CreateIndustryJobs
<
ActiveRecord
::
Migration
[
6.0
]
def
change
create_table
:industry_jobs
do
|
t
|
t
.
references
:industry
,
null:
false
,
foreign_key:
true
t
.
references
:job
,
null:
false
,
foreign_key:
true
t
.
references
:industry
,
foreign_key:
true
t
.
references
:job
,
foreign_key:
true
t
.
timestamps
end
...
...
db/migrate/20191202023059_add_company_code_to_company.rb
0 → 100644
View file @
8e2dcc16
class
AddCompanyCodeToCompany
<
ActiveRecord
::
Migration
[
6.0
]
def
change
add_column
:companies
,
:company_code
,
:string
,
unique:
true
end
end
db/migrate/20191202023440_add_index_to_company_code.rb
0 → 100644
View file @
8e2dcc16
class
AddIndexToCompanyCode
<
ActiveRecord
::
Migration
[
6.0
]
def
change
add_index
:companies
,
:company_code
,
unique:
true
end
end
db/schema.rb
View file @
8e2dcc16
...
...
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2019_1
1_26_083335
)
do
ActiveRecord
::
Schema
.
define
(
version:
2019_1
2_02_023440
)
do
create_table
"cities"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
,
force: :cascade
do
|
t
|
t
.
string
"name"
...
...
@@ -21,8 +21,8 @@ ActiveRecord::Schema.define(version: 2019_11_26_083335) do
end
create_table
"city_jobs"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
,
force: :cascade
do
|
t
|
t
.
bigint
"city_id"
,
null:
false
t
.
bigint
"job_id"
,
null:
false
t
.
bigint
"city_id"
t
.
bigint
"job_id"
t
.
datetime
"created_at"
,
precision:
6
,
null:
false
t
.
datetime
"updated_at"
,
precision:
6
,
null:
false
t
.
index
[
"city_id"
],
name:
"index_city_jobs_on_city_id"
...
...
@@ -36,6 +36,8 @@ ActiveRecord::Schema.define(version: 2019_11_26_083335) do
t
.
string
"address"
t
.
datetime
"created_at"
,
precision:
6
,
null:
false
t
.
datetime
"updated_at"
,
precision:
6
,
null:
false
t
.
string
"company_code"
t
.
index
[
"company_code"
],
name:
"index_companies_on_company_code"
,
unique:
true
t
.
index
[
"email"
],
name:
"index_companies_on_email"
,
unique:
true
end
...
...
@@ -55,8 +57,8 @@ ActiveRecord::Schema.define(version: 2019_11_26_083335) do
end
create_table
"industry_jobs"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
,
force: :cascade
do
|
t
|
t
.
bigint
"industry_id"
,
null:
false
t
.
bigint
"job_id"
,
null:
false
t
.
bigint
"industry_id"
t
.
bigint
"job_id"
t
.
datetime
"created_at"
,
precision:
6
,
null:
false
t
.
datetime
"updated_at"
,
precision:
6
,
null:
false
t
.
index
[
"industry_id"
],
name:
"index_industry_jobs_on_industry_id"
...
...
@@ -74,15 +76,15 @@ ActiveRecord::Schema.define(version: 2019_11_26_083335) do
t
.
integer
"category"
t
.
datetime
"post_date"
t
.
datetime
"expiration_date"
t
.
bigint
"company_id"
,
null:
false
t
.
bigint
"company_id"
t
.
datetime
"created_at"
,
precision:
6
,
null:
false
t
.
datetime
"updated_at"
,
precision:
6
,
null:
false
t
.
index
[
"company_id"
],
name:
"index_jobs_on_company_id"
end
create_table
"user_jobs"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
,
force: :cascade
do
|
t
|
t
.
bigint
"user_id"
,
null:
false
t
.
bigint
"job_id"
,
null:
false
t
.
bigint
"user_id"
t
.
bigint
"job_id"
t
.
datetime
"applied_at"
t
.
datetime
"viewed_at"
t
.
datetime
"favorited_at"
...
...
lib/.~lock.jobss.csv#
0 → 100644
View file @
8e2dcc16
,nghiann,devops-OptiPlex-3020,02.12.2019 09:27,file:///home/nghiann/.config/libreoffice/4;
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment