Commit 0e3f626d by Mai Hoang Thai Ha

fixed model and view

parent 7a1e0d6f
// @import "bootstrap"; // @import "bootstrap";
$white: #fff;
$gray-100: #f8f9fa;
$gray-200: #e9ecef;
$gray-300: #dee2e6;
$gray-400: #ced4da;
$gray-500: #adb5bd;
$gray-600: #6c757d;
$gray-700: #495057;
$gray-800: #343a40;
$gray-900: #212529;
$black: #000;
// reset css // reset css
*{ *{
...@@ -34,12 +23,12 @@ header { ...@@ -34,12 +23,12 @@ header {
li { li {
margin-left: 18px; margin-left: 18px;
a { a {
color: $gray-400; color: #ced4da;
font-size: 18px; font-size: 18px;
text-decoration: none; text-decoration: none;
font-weight: 500; font-weight: 500;
&:hover{ &:hover{
color: $white; color: #fff;
} }
} }
} }
...@@ -58,9 +47,9 @@ footer { ...@@ -58,9 +47,9 @@ footer {
color: #777; color: #777;
a { a {
text-decoration:none; text-decoration:none;
color: $gray-600; color: #6c757d;
&:hover { &:hover {
color: $gray-900; color: #212529;
} }
} }
small { small {
......
$white: #fff;
$gray-100: #f8f9fa;
$gray-200: #e9ecef;
$gray-300: #dee2e6;
$gray-400: #ced4da;
$gray-500: #adb5bd;
$gray-600: #6c757d;
$gray-700: #495057;
$gray-800: #343a40;
$gray-900: #212529;
$black: #000;
// Top page // Top page
// search // search
...@@ -29,7 +18,7 @@ $black: #000; ...@@ -29,7 +18,7 @@ $black: #000;
.job-company { .job-company {
text-decoration: none; text-decoration: none;
font-size: 14px; font-size: 14px;
color: $gray-700; color: #495057;
} }
.job-salary { .job-salary {
color: #008563; color: #008563;
...@@ -40,7 +29,7 @@ $black: #000; ...@@ -40,7 +29,7 @@ $black: #000;
list-style: none; list-style: none;
margin: 0 0 6px 0; margin: 0 0 6px 0;
padding: 0; padding: 0;
color: $gray-700; color: #495057;
} }
} }
.job-desc { .job-desc {
......
...@@ -2,7 +2,7 @@ class TopController < ApplicationController ...@@ -2,7 +2,7 @@ class TopController < ApplicationController
def index def index
@total_job = Job.count @total_job = Job.count
@latest_jobs = Job.latest @latest_jobs = Job.latest
@top_cities = City.top_jobs @top_cities = City.top_jobs.take(City::TOP_JOB_COUNT)
@top_industries = Industry.top_jobs @top_industries = Industry.job_quantity_by_industry.take(Industry::TOP_JOB_COUNT)
end end
end end
...@@ -8,8 +8,7 @@ class City < ApplicationRecord ...@@ -8,8 +8,7 @@ class City < ApplicationRecord
validates :slug, presence: true, uniqueness: { case_sensitive: true } validates :slug, presence: true, uniqueness: { case_sensitive: true }
def self.top_jobs def self.top_jobs
joins(:jobs).select('cities.*, count(jobs.id) as job_count') joins(:jobs).group(:name, :slug).order('COUNT(jobs.id) DESC').count
.group('cities.id').order('job_count desc').limit(TOP_JOB_COUNT)
end end
def self.job_quantity_by_region def self.job_quantity_by_region
......
...@@ -5,12 +5,7 @@ class Industry < ApplicationRecord ...@@ -5,12 +5,7 @@ class Industry < ApplicationRecord
validates :slug, presence: true, uniqueness: { case_sensitive: true } validates :slug, presence: true, uniqueness: { case_sensitive: true }
def self.top_jobs
joins(:jobs).select('industries.*, count(jobs.id) as job_count')
.group('industries.id').order('job_count desc').limit(TOP_JOB_COUNT)
end
def self.job_quantity_by_industry def self.job_quantity_by_industry
Industry.joins(:jobs).group(:name, :slug).order('COUNT(jobs.id) DESC').count joins(:jobs).group(:name, :slug).order('COUNT(jobs.id) DESC').count
end end
end end
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
- @regions.each do |region| - @regions.each do |region|
.col-lg-4.col-md-6.text-center .col-lg-4.col-md-6.text-center
.mt-5 .mt-5
h3.h4.mb-2.text-white.see-more-text= link_to region, anchor: region h3.h4.mb-2.text-white.see-more-text= link_to region.upcase, anchor: region
// cities list // cities list
.cities-list .cities-list
.container .container
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
.countries-job-list id=region .countries-job-list id=region
.container-fullwidth.py-5 .container-fullwidth.py-5
h2.mt-0 h2.mt-0
= region = region.upcase
hr.my-4 hr.my-4
.row .row
- city_job_count.each do |city, count| - city_job_count.each do |city, count|
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
.row.align-items-start.mb-3 .row.align-items-start.mb-3
- @top_cities.each do |city, city_jobs| - @top_cities.each do |city, city_jobs|
.col-4.city-item .col-4.city-item
= link_to city.name, job_list_path(model: :city, slug: city.slug), class: 'city-name' = link_to city[0], job_list_path(model: :city, slug: city[1]), class: 'city-name'
span.job-count span.job-count
| ( | (
= pluralize(city_jobs, 'job') = pluralize(city_jobs, 'job')
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
.row.align-items-start .row.align-items-start
- @top_industries.each do |industry, industry_jobs| - @top_industries.each do |industry, industry_jobs|
.col-4.industry-item .col-4.industry-item
= link_to industry.name, job_list_path(model: :industry, slug: industry.slug), class: 'industry-name' = link_to industry[0], job_list_path(model: :industry, slug: industry[1]), class: 'industry-name'
span.job-count span.job-count
| ( | (
= pluralize(industry_jobs, 'job') = pluralize(industry_jobs, 'job')
......
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