Commit d23eeafb by thanhnd

fix review toppage 20200226 1

parent b0c92715
Pipeline #479 failed with stages
in 0 seconds
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
* vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope.
*
*= require_tree .
*= require_self
*/
body {
padding: 0;
margin: 0;
background: #f2f6e9;
}
.rowtp {
color: red;
text-transform: uppercase;
text-align: center;
margin: auto;
width: 50%;
border: 3px solid green;
padding: 10px;
}
ul.class-name li {
float:left; width:50%;
}
.text {
display: block;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
#banner{
overflow: hidden;
background-image:url(https://ads.careerbuilder.vn/www/images/64ad182ac0b52d0f4c9bcc2bc24beb6b.jpg);
background-size:100% 100%;
}
/*--- navigation bar ---*/
.navbar {
background:#262626
}
.nav-link,
.navbar-brand {
color: #fff;
cursor: pointer;
}
.nav-link {
margin-right: 1em !important;
}
.nav-link:hover {
color: #000;
}
.navbar-collapse {
justify-content: flex-end;
}
...@@ -10,5 +10,71 @@ ...@@ -10,5 +10,71 @@
* files in this directory. Styles in this file should be added after the last require_* statement. * files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope. * It is generally better to create a new file per style scope.
* *
*= require_tree .
*= require_self
*/ */
@import "bootstrap"; @import "bootstrap";
body {
padding: 0;
margin: 0;
background: #f2f6e9;
}
.rowtp {
color: red;
text-transform: uppercase;
text-align: center;
margin: auto;
width: 50%;
border: 3px solid green;
padding: 10px;
}
.form-inline {
color: red;
text-transform: uppercase;
text-align: center;
margin: auto;
width: 50%;
padding: 10px;
}
ul.class-name li {
float:left; width:50%;
}
.text {
display: block;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
#banner{
overflow: hidden;
background-image:url(https://ads.careerbuilder.vn/www/images/64ad182ac0b52d0f4c9bcc2bc24beb6b.jpg);
background-size:100% 100%;
}
/*--- navigation bar ---*/
.navbar {
background:#262626
}
.nav-link,
.navbar-brand {
color: #fff;
cursor: pointer;
}
.nav-link {
margin-right: 1em !important;
}
.nav-link:hover {
color: #000;
}
.navbar-collapse {
justify-content: flex-end;
}
// Place all the styles related to the toppage controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/
class TopPageController < ApplicationController
def index
@total_jobs = Job.count
@latest_jobs = Job.latest_five_job
@top_industries = Industry.top_nine_industry
@top_cities = City.top_nine_city
end
end
class ToppageController < ApplicationController
def index
@totaljob = Job.all.count
@latestjobs = Job.order(:last_updated).first(5)
@topindustry = Industry.joins(:jobs).select('industries.*, COUNT(jobs.id) as jobcount').group('jobs.industry_id').order(:jobcount).last(9)
@topcity = City.joins(:jobs).select('cities.*, COUNT(jobs.id) as jobcount').group('jobs.city_id').order(:jobcount).last(9)
end
end
...@@ -2,4 +2,5 @@ class City < ApplicationRecord ...@@ -2,4 +2,5 @@ class City < ApplicationRecord
belongs_to :area belongs_to :area
has_many :jobs has_many :jobs
validates_presence_of :city_name validates_presence_of :city_name
scope :top_nine_city, ->{joins(:jobs).select('cities.*, COUNT(jobs.id) as jobcount').group('jobs.city_id').order(:jobcount).last(9)}
end end
...@@ -2,4 +2,5 @@ class Industry < ApplicationRecord ...@@ -2,4 +2,5 @@ class Industry < ApplicationRecord
has_many :industry_jobs has_many :industry_jobs
has_many :jobs has_many :jobs
validates_presence_of :industry_name validates_presence_of :industry_name
scope :top_nine_industry, ->{joins(:jobs).select('industries.*, COUNT(jobs.id) as jobcount').group('jobs.industry_id').order(:jobcount).last(9)}
end end
class Job < ApplicationRecord class Job < ApplicationRecord
has_many :industry_jobs has_many :industry_jobs
has_many :saved_jobs has_many :saved_jobs
has_many :applied_jobs has_many :applied_jobs
has_and_belongs_to_many :users has_and_belongs_to_many :users
belongs_to :area belongs_to :area
belongs_to :city belongs_to :city
belongs_to :company belongs_to :company
validates_presence_of :job_name validates_presence_of :job_name
scope :latest_five_job, ->{order(:last_updated).first(5)}
end end
<div id="banner" class="container p-5 my-2 bg-secondary text-white"> <div id="banner" class="container p-5 my-2 bg-secondary text-white">
<div class="rowtp")> <div class="rowtp">
<label> Total Jobs: <%= @totaljob %></label> <label> Total Jobs: <%= @total_jobs %></label>
</div> </div>
</div> </div>
...@@ -16,22 +16,22 @@ ...@@ -16,22 +16,22 @@
<div id="latestjobs"class="container p-5 my-2 bg-secondary text-white"> <div id="latestjobs"class="container p-5 my-2 bg-secondary text-white">
<font color="red"><b><label > Latest Jobs:</label></b></font> <font color="red"><b><label > Latest Jobs:</label></b></font>
<% @latestjobs.each do |j| %> <% @latest_jobs.each do |latest_job| %>
<ul> <ul>
<li><%= j.job_name %></li> <li><%= latest_job.job_name %></li>
<li><%= j.salary.to_s %></li> <li><%= latest_job.salary.to_s %></li>
<li><%= j.experience %></li> <li><%= latest_job.experience %></li>
<li><%= j.last_updated %></li> <li><%= latest_job.last_updated %></li>
<li ><span class="text"><%= j.description %></span></li> <li ><span class="text"><%= latest_job.description %></span></li>
</ul> </ul>
<% end %> <% end %>
</div> </div>
<div id="topcity" class="container p-5 my-2 bg-secondary text-white"> <div id="topcity" class="container p-5 my-2 bg-secondary text-white">
<font color="red"><b><label > Top Cities:</label></b></font> <font color="red"><b><label > Top Cities:</label></b></font>
<% @topcity.each do |j| %> <% @top_cities.each do |top_city| %>
<ul> <ul>
<li><%= j.city_name %></li> <li><%= top_city.city_name %></li>
</ul> </ul>
<% end %> <% end %>
</div> </div>
...@@ -39,9 +39,9 @@ ...@@ -39,9 +39,9 @@
<div id="topindustry" class="container p-5 my-2 bg-secondary text-white"> <div id="topindustry" class="container p-5 my-2 bg-secondary text-white">
<font color="red"><b><label > Top Industry:</label></b></font> <font color="red"><b><label > Top Industry:</label></b></font>
<% @topindustry.each do |j| %> <% @top_industries.each do |top_industy| %>
<ul> <ul>
<li><%= j.industry_name %></li> <li><%= top_industy.industry_name %></li>
</ul> </ul>
<% end %> <% end %>
</div> </div>
......
Rails.application.routes.draw do Rails.application.routes.draw do
root 'toppage#index' root 'top_page#index'
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
resources :toppage resources :top_page
end end
...@@ -59,9 +59,11 @@ namespace :crawler do ...@@ -59,9 +59,11 @@ namespace :crawler do
company = Company.find_or_create_by(company_name: company_name.text, company_description: company_intro.text, address: address.text) company = Company.find_or_create_by(company_name: company_name.text, company_description: company_intro.text, address: address.text)
#insert data to Jobs table #insert data to Jobs table
Job.find_or_create_by(area_id: area.id, city_id: city.id , industry_id: industry.id, company_id: company.id, job_name: title.text, salary: salary.text, deadline: deadline.text, level: level.text, experience: experience.text.strip, last_updated: updated_date.text.strip, description: description.text) job_table = Job.find_or_create_by(area_id: area.id, city_id: city.id , industry_id: industry.id, company_id: company.id, job_name: title.text, salary: salary.text, deadline: deadline.text, level: level.text, experience: experience.text.strip, last_updated: updated_date.text.strip, description: description.text)
#insert data to Industry_Jobs table
IndustryJob.find_or_create_by(industry_id: industry.id , job_id: job_table.id)
#industryjob = IndustryJob.find_or_create_by(industry_id: industry.industry_id , job_id: job.job_id)
end end
list_url = nextpage[0]["href"] list_url = nextpage[0]["href"]
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
"@rails/ujs": "^6.0.0", "@rails/ujs": "^6.0.0",
"@rails/webpacker": "4.2.2", "@rails/webpacker": "4.2.2",
"bootstrap": "^4.4.1", "bootstrap": "^4.4.1",
"bootstrapp": "^0.0.0",
"jquery": "^3.4.1", "jquery": "^3.4.1",
"popper.js": "^1.16.1", "popper.js": "^1.16.1",
"turbolinks": "^5.2.0" "turbolinks": "^5.2.0"
......
require 'test_helper'
class ToppageControllerTest < ActionDispatch::IntegrationTest
test "should get index" do
get toppage_index_url
assert_response :success
end
end
...@@ -1391,15 +1391,6 @@ bootstrap@^4.4.1: ...@@ -1391,15 +1391,6 @@ bootstrap@^4.4.1:
resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-4.4.1.tgz#8582960eea0c5cd2bede84d8b0baf3789c3e8b01" resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-4.4.1.tgz#8582960eea0c5cd2bede84d8b0baf3789c3e8b01"
integrity sha512-tbx5cHubwE6e2ZG7nqM3g/FZ5PQEDMWmMGNrCUBVRPHXTJaH7CBDdsLeu3eCh3B1tzAxTnAbtmrzvWEvT2NNEA== integrity sha512-tbx5cHubwE6e2ZG7nqM3g/FZ5PQEDMWmMGNrCUBVRPHXTJaH7CBDdsLeu3eCh3B1tzAxTnAbtmrzvWEvT2NNEA==
bootstrapp@^0.0.0:
version "0.0.0"
resolved "https://registry.yarnpkg.com/bootstrapp/-/bootstrapp-0.0.0.tgz#5e2edd782ab7bc9addfadf412835e60c43221076"
integrity sha1-Xi7deCq3vJrd+t9BKDXmDEMiEHY=
dependencies:
erros "0.0.1"
express "^4.8.8"
middle-earth "0.0.6"
brace-expansion@^1.1.7: brace-expansion@^1.1.7:
version "1.1.11" version "1.1.11"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
...@@ -2567,13 +2558,6 @@ error-ex@^1.2.0, error-ex@^1.3.1: ...@@ -2567,13 +2558,6 @@ error-ex@^1.2.0, error-ex@^1.3.1:
dependencies: dependencies:
is-arrayish "^0.2.1" is-arrayish "^0.2.1"
erros@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/erros/-/erros-0.0.1.tgz#f5de1b3d5e90088bff231a52241cedb04ed8ebcf"
integrity sha1-9d4bPV6QCIv/IxpSJBztsE7Y688=
dependencies:
express "^4.1.1"
es-abstract@^1.17.0-next.1, es-abstract@^1.17.2: es-abstract@^1.17.0-next.1, es-abstract@^1.17.2:
version "1.17.4" version "1.17.4"
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.17.4.tgz#e3aedf19706b20e7c2594c35fc0d57605a79e184" resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.17.4.tgz#e3aedf19706b20e7c2594c35fc0d57605a79e184"
...@@ -2703,7 +2687,7 @@ expand-tilde@^2.0.0, expand-tilde@^2.0.2: ...@@ -2703,7 +2687,7 @@ expand-tilde@^2.0.0, expand-tilde@^2.0.2:
dependencies: dependencies:
homedir-polyfill "^1.0.1" homedir-polyfill "^1.0.1"
express@^4.0.0, express@^4.1.1, express@^4.17.1, express@^4.8.8: express@^4.17.1:
version "4.17.1" version "4.17.1"
resolved "https://registry.yarnpkg.com/express/-/express-4.17.1.tgz#4491fc38605cf51f8629d39c2b5d026f98a4c134" resolved "https://registry.yarnpkg.com/express/-/express-4.17.1.tgz#4491fc38605cf51f8629d39c2b5d026f98a4c134"
integrity sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g== integrity sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==
...@@ -4258,13 +4242,6 @@ micromatch@^3.0.4, micromatch@^3.1.10, micromatch@^3.1.4: ...@@ -4258,13 +4242,6 @@ micromatch@^3.0.4, micromatch@^3.1.10, micromatch@^3.1.4:
snapdragon "^0.8.1" snapdragon "^0.8.1"
to-regex "^3.0.2" to-regex "^3.0.2"
middle-earth@0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/middle-earth/-/middle-earth-0.0.6.tgz#83551b62767e5c170d7c1139754685064008595b"
integrity sha1-g1UbYnZ+XBcNfBE5dUaFBkAIWVs=
dependencies:
express "^4.0.0"
miller-rabin@^4.0.0: miller-rabin@^4.0.0:
version "4.0.1" version "4.0.1"
resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d" resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment