fix view ID4

parent e25c9b9b
Pipeline #1378 failed with stages
in 0 seconds
...@@ -42,4 +42,18 @@ ...@@ -42,4 +42,18 @@
.form { .form {
width: 700px width: 700px
} }
\ No newline at end of file
.card-body {
float: left;
}
.favourite {
float: right;
.btn {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
}
...@@ -2,10 +2,10 @@ class JobsController < ApplicationController ...@@ -2,10 +2,10 @@ class JobsController < ApplicationController
def show def show
if params[:city_slug].present? if params[:city_slug].present?
@city = City.find_by(slug: params[:city_slug]) @city = City.find_by(slug: params[:city_slug])
@jobs = @city.jobs.order(created_at: :desc).page(params[:page]).per(20) @jobs = @city.jobs.latest_jobs.page(params[:page])
elsif params[:industry_slug].present? else
@industry = Industry.find_by(slug: params[:industry_slug]) @industry = Industry.find_by(slug: params[:industry_slug])
@jobs = @industry.jobs.order(created_at: :desc).page(params[:page]).per(20) @jobs = @industry.jobs.latest_jobs.page(params[:page])
end end
end end
end end
\ No newline at end of file
class TopController < ApplicationController class TopController < ApplicationController
def home def home
@jobs = Job.latest_jobs @jobs = Job.latest_jobs.limit(Job::LATEST_JOB_NUMBER)
@cities = City.top_cities @cities = City.top_cities
@industries = Industry.top_industries @industries = Industry.top_industries
@total_job = Job.all.count @total_job = Job.count
end end
end end
\ No newline at end of file
class City < ApplicationRecord class City < ApplicationRecord
extend FriendlyId
friendly_id :name, use: %i[slugged finders]
belongs_to :region belongs_to :region
has_and_belongs_to_many :jobs has_and_belongs_to_many :jobs
has_and_belongs_to_many :companies has_and_belongs_to_many :companies
LATEST_CITY_NUMBER = 9 LATEST_CITY_NUMBER = 9
REGION_VN_ID = 1 REGION_VN_ID = 1
REGION_INTERNATIONAL_ID = 2 REGION_INTERNATIONAL_ID = 2
scope :top_cities, -> { joins(:jobs).group(:name).order('count_all DESC').count.take(LATEST_CITY_NUMBER) }
scope :cities_by_region, ->(value) { joins(:jobs).group(:name).having('count_all >= ?', 1).where('region_id = ?', value).order('count_all DESC').count } scope :top_cities, -> { joins(:jobs).group(:name, :slug).order('count_all DESC').count.take(LATEST_CITY_NUMBER) }
extend FriendlyId scope :cities_by_region, ->(value) { joins(:jobs).group(:name, :slug).having('count_all >= ?', 1).where('region_id = ?', value).order('count_all DESC').count }
friendly_id :name, use: %i[slugged finders]
def normalize_friendly_id(string) def normalize_friendly_id(string)
string.to_s.to_slug.normalize(transliterations: :vietnamese).to_s string.to_s.to_slug.normalize(transliterations: :vietnamese).to_s
end end
......
class Industry < ApplicationRecord class Industry < ApplicationRecord
has_and_belongs_to_many :jobs
LATEST_INDUSTRY_NUMBER = 9
scope :top_industries, -> { joins(:jobs).group(:name).order('count_all DESC').count.take(LATEST_INDUSTRY_NUMBER) }
scope :industry_list, -> { joins(:jobs).group(:name).having('count_all >= ?', 1).order('count_all DESC').count }
extend FriendlyId extend FriendlyId
friendly_id :name, use: %i[slugged finders] friendly_id :name, use: %i[slugged finders]
has_and_belongs_to_many :jobs
LATEST_INDUSTRY_NUMBER = 9
scope :top_industries, -> { joins(:jobs).group(:name, :slug).order('count_all DESC').count.take(LATEST_INDUSTRY_NUMBER) }
scope :industry_list, -> { joins(:jobs).group(:name, :slug).having('count_all >= ?', 1).order('count_all DESC').count }
def normalize_friendly_id(string) def normalize_friendly_id(string)
string.to_s.to_slug.normalize(transliterations: :vietnamese).to_s string.to_s.to_slug.normalize(transliterations: :vietnamese).to_s
end end
......
...@@ -6,5 +6,5 @@ class Job < ApplicationRecord ...@@ -6,5 +6,5 @@ class Job < ApplicationRecord
has_and_belongs_to_many :industries has_and_belongs_to_many :industries
has_and_belongs_to_many :cities has_and_belongs_to_many :cities
LATEST_JOB_NUMBER = 5 LATEST_JOB_NUMBER = 5
scope :latest_jobs, -> { includes(:cities, :company).order('created_at DESC').limit(LATEST_JOB_NUMBER) } scope :latest_jobs, -> { includes(:cities, :industries, :company).order('created_at DESC') }
end end
\ No newline at end of file
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
.row.my-3.text-center.fs-5 .row.my-3.text-center.fs-5
- @cities_vietnam.each do |name, amount| - @cities_vietnam.each do |name, amount|
.col-3.p-2.border.mb-1.fw-normal.bg-white .col-3.p-2.border.mb-1.fw-normal.bg-white
= link_to name, city_slug_path(City.find_by(name: name)) = link_to name[0], city_slug_path(name[1])
p.mb-1 p.mb-1
= amount = amount
#international #international
...@@ -23,6 +23,6 @@ ...@@ -23,6 +23,6 @@
.row.my-3.text-center.fs-5 .row.my-3.text-center.fs-5
- @cities_international.each do |name, amount| - @cities_international.each do |name, amount|
.col-3.p-2.border.mb-1.fw-normal.bg-white .col-3.p-2.border.mb-1.fw-normal.bg-white
= link_to name, city_slug_path(City.find_by(name: name)) = link_to name[0], city_slug_path(name[1])
p.mb-1 p.mb-1
= amount = amount
\ No newline at end of file
...@@ -6,6 +6,6 @@ ...@@ -6,6 +6,6 @@
.row.my-3.text-center.fs-5 .row.my-3.text-center.fs-5
- @industry_list.each do |name, amount| - @industry_list.each do |name, amount|
.col-3.p-2.border.mb-1.fw-normal.bg-white .col-3.p-2.border.mb-1.fw-normal.bg-white
= link_to name, industry_slug_path(Industry.friendly.find_by(name: name)) = link_to name[0], industry_slug_path(name[1])
p.mb-1 p.mb-1
= amount = amount
\ No newline at end of file
.search.p-3.offset-md-2 .search.p-3.offset-md-2
= form_with(url: '/search', method: 'get', local: true) do = form_with(url: '/jobs', method: 'get', local: true) do
= text_field_tag :search, params[:search], placeholder: "Search", class: "form" = text_field_tag :search, params[:search], placeholder: "Search", class: "form"
= submit_tag "Search", name: nil, class: 'btn-primary' = submit_tag "Search", name: nil, class: 'btn-primary'
\ No newline at end of file
...@@ -2,12 +2,16 @@ ...@@ -2,12 +2,16 @@
= render 'search' = render 'search'
.container .container
h5.fw-normal
| Total:
h5.fw-normal
| Result for:
h6.offset-md-4 h6.offset-md-4
= paginate @jobs, window: 1 = paginate @jobs, window: 1
.job-list .job-list
- @jobs.each do |job| - @jobs.each do |job|
.card.my-3 .row.bg-white
.card-body.text-dark .col-10.p-3.border.card-body.text-dark
h5.mb-1 h5.mb-1
= link_to job.title, "#" = link_to job.title, "#"
p.mb-1 p.mb-1
...@@ -21,7 +25,9 @@ ...@@ -21,7 +25,9 @@
= link_to job.cities.map(&:name).uniq.join(' | '), "#" = link_to job.cities.map(&:name).uniq.join(' | '), "#"
p.mb-1 p.mb-1
= truncate(job.overview, length: 250) = truncate(job.overview, length: 250)
.col-sm-2.p-3.border.favourite
= link_to "Farourite", "#", class: "btn btn-outline-primary"
h6.offset-md-4.px-5 h6.offset-md-4.px-5
= page_entries_info @jobs = page_entries_info @jobs
h6.offset-md-4 h6.offset-md-4
= paginate @jobs, window: 1 = paginate @jobs, window: 1
\ No newline at end of file
...@@ -26,7 +26,7 @@ h3.p-2 ...@@ -26,7 +26,7 @@ h3.p-2
.row.my-3.text-center.fs-5 .row.my-3.text-center.fs-5
- @cities.each do |name, amount| - @cities.each do |name, amount|
.col-4.p-2.border.mb-1.fw-normal.bg-white .col-4.p-2.border.mb-1.fw-normal.bg-white
= link_to name, city_slug_path(City.find_by(name: name)) = link_to name[0], city_slug_path(name[1])
p.mb-1 p.mb-1
= amount = amount
.d-flex.flex-row-reverse. .d-flex.flex-row-reverse.
...@@ -36,7 +36,7 @@ h3.p-2 ...@@ -36,7 +36,7 @@ h3.p-2
.row.my-3.text-center.fs-5 .row.my-3.text-center.fs-5
- @industries.each do |name, amount| - @industries.each do |name, amount|
.col-4.p-2.border.mb-1.fw-normal.bg-white .col-4.p-2.border.mb-1.fw-normal.bg-white
= link_to name, industry_slug_path(Industry.find_by(name: name)) = link_to name[0], industry_slug_path(name[1])
p.mb-1 p.mb-1
= amount = amount
.d-flex.flex-row-reverse .d-flex.flex-row-reverse
......
# frozen_string_literal: true # frozen_string_literal: true
Kaminari.configure do |config| Kaminari.configure do |config|
# config.default_per_page = 25 config.default_per_page = 20
# config.max_per_page = nil # config.max_per_page = nil
# config.window = 4 # config.window = 4
# config.outer_window = 0 # config.outer_window = 0
......
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