fix view ID4

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