Commit c88e02de by Trịnh Hoàng Phúc

Merge branch 'feature/social_authenticate' into 'master'

Fix review 18/05/2020

See merge request !21
parents afbc5c47 a95865dc
Pipeline #636 failed with stages
in 0 seconds
......@@ -4,7 +4,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.7.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.2', '>= 6.0.2.2'
gem 'rails', '~> 6.0', '>= 6.0.3'
# Use sqlite3 as the database for Active Record
# gem 'sqlite3', '~> 1.4'
gem 'mysql2'
......
GEM
remote: https://rubygems.org/
specs:
actioncable (6.0.2.2)
actionpack (= 6.0.2.2)
actioncable (6.0.3)
actionpack (= 6.0.3)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.0.2.2)
actionpack (= 6.0.2.2)
activejob (= 6.0.2.2)
activerecord (= 6.0.2.2)
activestorage (= 6.0.2.2)
activesupport (= 6.0.2.2)
actionmailbox (6.0.3)
actionpack (= 6.0.3)
activejob (= 6.0.3)
activerecord (= 6.0.3)
activestorage (= 6.0.3)
activesupport (= 6.0.3)
mail (>= 2.7.1)
actionmailer (6.0.2.2)
actionpack (= 6.0.2.2)
actionview (= 6.0.2.2)
activejob (= 6.0.2.2)
actionmailer (6.0.3)
actionpack (= 6.0.3)
actionview (= 6.0.3)
activejob (= 6.0.3)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.0.2.2)
actionview (= 6.0.2.2)
activesupport (= 6.0.2.2)
actionpack (6.0.3)
actionview (= 6.0.3)
activesupport (= 6.0.3)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.0.2.2)
actionpack (= 6.0.2.2)
activerecord (= 6.0.2.2)
activestorage (= 6.0.2.2)
activesupport (= 6.0.2.2)
actiontext (6.0.3)
actionpack (= 6.0.3)
activerecord (= 6.0.3)
activestorage (= 6.0.3)
activesupport (= 6.0.3)
nokogiri (>= 1.8.5)
actionview (6.0.2.2)
activesupport (= 6.0.2.2)
actionview (6.0.3)
activesupport (= 6.0.3)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (6.0.2.2)
activesupport (= 6.0.2.2)
activejob (6.0.3)
activesupport (= 6.0.3)
globalid (>= 0.3.6)
activemodel (6.0.2.2)
activesupport (= 6.0.2.2)
activerecord (6.0.2.2)
activemodel (= 6.0.2.2)
activesupport (= 6.0.2.2)
activemodel (6.0.3)
activesupport (= 6.0.3)
activerecord (6.0.3)
activemodel (= 6.0.3)
activesupport (= 6.0.3)
activerecord-import (1.0.4)
activerecord (>= 3.2)
activestorage (6.0.2.2)
actionpack (= 6.0.2.2)
activejob (= 6.0.2.2)
activerecord (= 6.0.2.2)
activestorage (6.0.3)
actionpack (= 6.0.3)
activejob (= 6.0.3)
activerecord (= 6.0.3)
marcel (~> 0.3.1)
activesupport (6.0.2.2)
activesupport (6.0.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2)
zeitwerk (~> 2.2, >= 2.2.2)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
bcrypt (3.1.13)
......@@ -68,8 +68,8 @@ GEM
bootsnap (1.4.6-java)
msgpack (~> 1.0)
builder (3.2.4)
byebug (11.1.1)
capybara (3.32.0)
byebug (11.1.3)
capybara (3.32.2)
addressable
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
......@@ -106,7 +106,7 @@ GEM
hashie (4.1.0)
i18n (1.8.2)
concurrent-ruby (~> 1.0)
image_processing (1.10.3)
image_processing (1.11.0)
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3)
jbuilder (2.10.0)
......@@ -128,7 +128,7 @@ GEM
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
loofah (2.4.0)
loofah (2.5.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
......@@ -138,11 +138,11 @@ GEM
meta-tags (2.13.0)
actionpack (>= 3.2.0, < 6.1)
method_source (1.0.0)
mimemagic (0.3.4)
mimemagic (0.3.5)
mini_magick (4.10.1)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.14.0)
minitest (5.14.1)
msgpack (1.3.3)
msgpack (1.3.3-java)
msgpack (1.3.3-x64-mingw32)
......@@ -179,14 +179,14 @@ GEM
omniauth (~> 1.9)
orm_adapter (0.5.0)
parallel (1.19.1)
pry (0.13.0)
pry (0.13.1)
coderay (~> 1.1)
method_source (~> 1.0)
pry (0.13.0-java)
pry (0.13.1-java)
coderay (~> 1.1)
method_source (~> 1.0)
spoon (~> 0.0)
public_suffix (4.0.3)
public_suffix (4.0.5)
puma (4.3.3)
nio4r (~> 2.0)
puma (4.3.3-java)
......@@ -196,34 +196,34 @@ GEM
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.0.2.2)
actioncable (= 6.0.2.2)
actionmailbox (= 6.0.2.2)
actionmailer (= 6.0.2.2)
actionpack (= 6.0.2.2)
actiontext (= 6.0.2.2)
actionview (= 6.0.2.2)
activejob (= 6.0.2.2)
activemodel (= 6.0.2.2)
activerecord (= 6.0.2.2)
activestorage (= 6.0.2.2)
activesupport (= 6.0.2.2)
rails (6.0.3)
actioncable (= 6.0.3)
actionmailbox (= 6.0.3)
actionmailer (= 6.0.3)
actionpack (= 6.0.3)
actiontext (= 6.0.3)
actionview (= 6.0.3)
activejob (= 6.0.3)
activemodel (= 6.0.3)
activerecord (= 6.0.3)
activestorage (= 6.0.3)
activesupport (= 6.0.3)
bundler (>= 1.3.0)
railties (= 6.0.2.2)
railties (= 6.0.3)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (6.0.2.2)
actionpack (= 6.0.2.2)
activesupport (= 6.0.2.2)
railties (6.0.3)
actionpack (= 6.0.3)
activesupport (= 6.0.3)
method_source
rake (>= 0.8.7)
thor (>= 0.20.3, < 2.0)
rake (13.0.1)
rb-fsevent (0.10.3)
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
regexp_parser (1.7.0)
......@@ -239,11 +239,9 @@ GEM
rubyzip (2.3.0)
sass-rails (6.0.0)
sassc-rails (~> 2.1, >= 2.1.1)
sassc (2.2.1)
sassc (2.3.0)
ffi (~> 1.9)
sassc (2.2.1-x64-mingw32)
ffi (~> 1.9)
sassc (2.2.1-x86-mingw32)
sassc (2.3.0-x64-mingw32)
ffi (~> 1.9)
sassc-rails (2.1.2)
railties (>= 4.0.0)
......@@ -275,18 +273,18 @@ GEM
turbolinks (5.2.1)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
tzinfo (1.2.6)
tzinfo (1.2.7)
thread_safe (~> 0.1)
tzinfo-data (1.2019.3)
tzinfo-data (1.2020.1)
tzinfo (>= 1.0.0)
warden (1.2.8)
rack (>= 2.0.6)
web-console (4.0.1)
web-console (4.0.2)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
bindex (>= 0.4.0)
railties (>= 6.0.0)
webdrivers (4.2.0)
webdrivers (4.3.0)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (>= 3.0, < 4.0)
......@@ -328,7 +326,7 @@ DEPENDENCIES
parallel
pry
puma (~> 4.1)
rails (~> 6.0.2, >= 6.0.2.2)
rails (~> 6.0, >= 6.0.3)
rsolr
sass-rails (>= 6)
selenium-webdriver
......
......@@ -25,7 +25,7 @@
},
error: (err) => {
if(err.status === 401){
if(confirm(err.responseJSON.message)){
if(confirm(err.responseText)){
window.location.href = "/users/sign_in";
}
}
......@@ -55,7 +55,7 @@
},
error: (err) => {
if(err.status === 401){
if(confirm(err.responseJSON.message)){
if(confirm(err.responseText)){
window.location.href = "/users/sign_in";
}
}
......@@ -78,7 +78,7 @@
},
error: (err) => {
if(err.status === 401){
if(confirm(err.responseJSON.message)){
if(confirm(err.responseText)){
window.location.href = "/users/sign_in";
}
}
......
// Place all the styles related to the pages controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/
class AdminsController < ApplicationController
before_action :authenticate_admin!
def applies
@cities = City.order("title ASC").all
@industries = Industry.order("title ASC").all
......
module CookiesHistory
def set_job_histories
arr_job_ids = cookies[:job_ids_history].to_s.split(",")
unless arr_job_ids.include? (@job.id.to_s)
arr_job_ids.shift if arr_job_ids.count == 10
arr_job_ids << @job.id.to_s
end
cookies[:job_ids_history] = { value: arr_job_ids.join(","), expires: Time.now + 3600 }
end
end
\ No newline at end of file
class HistoryController < ApplicationController
def index
if cookies[:job_ids_history].nil?
redirect_to "/jobs"
if user_signed_in?
@jobs_history = History.includes(:job, :user).where(user_id: current_user.id).order(updated_at: :desc)
else
arr_job_ids = cookies[:job_ids_history].split(",")
job_ids = cookies[:job_ids_history].split(",")
@jobs_history = Job.where("id IN (?)", job_ids).order("id DESC")
@jobs_history = Job.find(job_ids).reverse
end
end
end
\ No newline at end of file
class HomeController < ApplicationController
def index
@amount_job = Job.count
@latest_jobs = Job.last(Settings.home.limit)
@latest_cities = City.last(Settings.home.limit - 2)
@latest_industries = Industry.last(Settings.home.limit - 2)
@latest_jobs = Job.latest_jobs
@latest_cities = City.jobs_count_order_by
@latest_industries = Industry.jobs_count_order_by
end
end
class JobsController < ApplicationController
include CookiesHistory
def index
if params[:city_id]
@jobs = Job.by_cities(params[:city_id]).page(params[:page])
......@@ -10,35 +12,29 @@ class JobsController < ApplicationController
@jobs = Job.by_companies(params[:company_id]).page(params[:page])
@amount_job = Job.by_companies(params[:company_id]).count
else
@jobs = Job.order("id DESC").page(params[:page])
@jobs = Job.order(id: :desc).page(params[:page])
@amount_job = Job.count
end
end
def show
@job = Job.find_by(id: params[:id])
if @job.present?
@title = @job.title
return redirect_to page_404_path if @job.blank?
if user_signed_in?
@apply = Apply.find_by(job_id: params[:id], user_id: current_user.id)
@favorite = Favorite.find_by(job_id: params[:id], user_id: current_user.id)
end
@relate_jobs = Job.where("company_id = ? and id != ?", @job.company_id, @job.id).order("id DESC")
if cookies[:job_ids_history].nil?
cookies[:job_ids_history] = {value: @job.id, expires: Time.now + 3600}
@history = History.find_by(user_id: current_user.id, job_id: params[:id])
if @history.nil?
History.create(user_id: current_user.id, job_id: params[:id])
else
arr_job_ids = cookies[:job_ids_history].split(",")
unless arr_job_ids.include?(@job.id.to_s)
if arr_job_ids.count == 10
arr_job_ids.shift
end
arr_job_ids << @job.id.to_s
end
cookies[:job_ids_history] = {value: arr_job_ids.join(","), expires: Time.now + 3600}
@history.update(updated_at: Time.now)
end
else
@title = "Job was not found"
set_job_histories
end
@relate_jobs = Job.related_jobs(@job.company_id, @job.id)
end
def search
return redirect_to root_path, alert: "Empty field!" if params[:keyword].blank?
response = RsolrService.new.query_job("job_title:#{params[:keyword]}", params[:page])
......
class PagesController < ApplicationController
def page_404
end
end
class UsersController < ApplicationController
before_action :authenticate_user!
def info
unless user_signed_in?
redirect_to "/users/sign_in"
end
end
def apply_jobs
unless user_signed_in?
redirect_to "/users/sign_in"
else
@applied_jobs = Apply.where("user_id = ?", current_user.id)
end
@applied_jobs = Apply.where("user_id = #{current_user.id}")
end
def favorite_jobs
unless user_signed_in?
redirect_to "/users/sign_in"
else
@favorite_jobs = Favorite.where("user_id = ?", current_user.id)
end
@favorite_jobs = Favorite.where("user_id = #{current_user.id}")
end
def apply_or_favorite_jobs
unless user_signed_in?
payload = {
message: "You are not logged in, please login to operate the feature",
}
render :json => payload, :status => :unauthorized
else
if params[:job_ids].present?
params[:job_ids].each do |id|
if params[:type] == "apply"
......@@ -39,14 +27,8 @@ class UsersController < ApplicationController
render :json => payload, :status => :ok
end
end
end
def remove_favorite_job
unless user_signed_in?
payload = {
message: "You are not logged in, please login to operate the feature",
}
render :json => payload, :status => :unauthorized
else
if params[:favorite_id].present?
Favorite.find_by(id: params[:favorite_id]).destroy
payload = {
......@@ -55,5 +37,4 @@ class UsersController < ApplicationController
render :json => payload, :status => :ok
end
end
end
end
module PagesHelper
end
......@@ -2,4 +2,12 @@ class City < ApplicationRecord
validates :title, presence: true, uniqueness: true
has_and_belongs_to_many :jobs
def jobs_count
@jobs_count ||= jobs.size
end
def self.jobs_count_order_by
@jobs_count_order_by ||= includes(:jobs).sort_by(&:jobs_count).reverse.take(Settings.home.limit + 2)
end
end
class History < ApplicationRecord
belongs_to :user
belongs_to :job
end
......@@ -2,4 +2,12 @@ class Industry < ApplicationRecord
validates :title, presence: true, uniqueness: true
has_and_belongs_to_many :jobs
def jobs_count
@jobs_count ||= jobs.size
end
def self.jobs_count_order_by
@jobs_count_order_by ||= includes(:jobs).sort_by(&:jobs_count).reverse.take(Settings.home.limit + 2)
end
end
class Job < ApplicationRecord
scope :by_cities, -> (city_id) {includes(:cities).where("cities.id = ?", city_id).references(:cities)}
scope :by_industries, -> (industry_id) {includes(:industries).where("industries.id = ?", industry_id).references(:industries)}
scope :by_companies, -> (company_id) {where("company_id = #{company_id}")}
scope :by_companies, -> (company_id) {where("company_id = ?", company_id)}
EXPORT_CSV_ATTRIBUTES = %w(title updated_date_job level years_of_experience salary expiration_date).freeze
......@@ -9,7 +9,8 @@ class Job < ApplicationRecord
has_many :applies
has_many :users, through: :applies
has_many :histories
has_many :users, through: :histories
has_many :favorites
has_many :users, through: :favorites
......@@ -27,4 +28,14 @@ class Job < ApplicationRecord
errors.add(:updated_date_job, "can't be greater than expiration date")
end
end
def self.latest_jobs
@latest_jobs ||= includes(:cities, :company).last(Settings.home.limit)
end
def self.related_jobs(company_id, job_id)
@related_jobs ||= includes(:cities, :company).where.not(id: job_id)
.where(company_id: company_id)
.limit(10)
end
end
......@@ -8,6 +8,8 @@ class User < ApplicationRecord
has_many :jobs, through: :applies
has_many :favorites
has_many :jobs, through: :favorites
has_many :histories
has_many :jobs, through: :histories
mount_uploader :cv, CvUploader
......
require "rsolr"
class RsolrService
attr_accessor :solr_job, :solr_apply, :apply, :job
attr_accessor :solr_job, :job
def initialize
@solr_job = RSolr.connect :url => "http://localhost:8983/solr/job"
@solr_apply = RSolr.connect :url => "http://localhost:8983/solr/apply"
@apply = nil
@job = nil
end
def query_apply(query_params, page)
apply = solr_apply.paginate page, Settings.admin.limit, "select", :params => {
:q=>query_params
}
apply["response"]["docs"]
end
def query_job(query_params, page)
job = solr_job.paginate page, Settings.search.limit, "select", :params => {
:q=>query_params
......
<%= content_for :title, "VenJob - Admin Applies" %>
<% set_meta_tags title: "VenJob - Admin Applies",
description: "VenJob - Admin Applies",
keywords: "VenJob - Admin Applies" %>
<div id="primary" class="content-area container" role="main">
<div class="row">
<div class="col-sm-12 col-md-10 col-md-offset-1">
......
<% content_for :title, "VenJob - Edit #{resource_name.to_s.humanize}" %>
<% set_meta_tags title: "VenJob - Edit #{resource_name.to_s.humanize}",
description: "VenJob - Edit #{resource_name.to_s.humanize}",
keywords: "VenJob - Edit #{resource_name.to_s.humanize}" %>
<header class="page-header">
<h2 class="page-title">Edit <%= resource_name.to_s.humanize %></h2>
</header>
......
......@@ -36,6 +36,7 @@
<p class="actions">
<%= f.submit "Sign up", class: "button" %>
<%= link_to "Sign in with Facebook", user_facebook_omniauth_authorize_path, class: "button" %>
</p>
<% end %>
<p>
......
......@@ -20,27 +20,7 @@
</tr>
</thead>
<tbody>
<% @jobs_history.each_with_index do |job, index| %>
<tr class="woocommerce-cart-form__cart-item cart_item">
<td>
<%= index + 1%>
</td>
<td style="text-align: center;">
<input type="checkbox" class="checkbox-apply-job" data-id="<%= job.id %>">
</td>
<td>
<%= link_to job.title, job %>
</td>
<td>
<% job.cities.each_with_index do |city, index| %>
<%= city.title %><%= ", " if index != job.cities.size - 1 %>
<% end %>
</td>
<td class="product-price">
<%= job.salary %>
</td>
</tr>
<% end %>
<%= render partial: (user_signed_in? ? '/shared/history_item_has_user' : '/shared/history_item_has_not_user'), collection: @jobs_history, as: :history_item %>
<tr>
<td colspan="6" class="actions">
<a class="button apply-all-job" href="javascript:void(0)">Apply all</a>
......
......@@ -30,37 +30,8 @@
<h3 class="widget-title widget-title--home">Total Jobs: <%= @amount_job %></h3>
<div class="job_listings">
<ul class="job_listings">
<% @latest_jobs.each do |job| %>
<li class="job_listing job-type-part-time post-3354 type-job_listing status-publish has-post-thumbnail hentry job_listing_category-design job_listing_type-part-time">
<div class="job_listing-logo">
<%= link_to(job) do %>
<img class="company_logo" src="<%= job.company.logo != "" ? job.company.logo : "https://via.placeholder.com/66x38?text=Logo" %>" alt="<%= job.company.title %>" />
<% end %>
</div>
<div class="job_listing-about">
<div class="job_listing-position job_listing__column">
<h3 class="job_listing-title">
<%= link_to job.title, job %>
</h3>
<div class="job_listing-company">
<strong>
<%= link_to job.company.title, jobs_with_company_path(company_id: job.company.id) %>
</strong>
</div>
</div>
<div class="job_listing-location job_listing__column">
<% job.cities.each_with_index do |city, index| %>
<%= link_to jobs_with_city_path(city_id: city.id), class: "google_map_link" do %>
<%= city.title %><%= ", " if index != job.cities.size - 1 %>
<% end %>
<% end %>
</div>
<ul class="job_listing-meta job_listing__column">
<li class="job_listing-type job-type part-time"><%= job.salary %></li>
<li class="job_listing-date"><%= job.expiration_date %></li>
</ul>
</div>
</li>
<% if @latest_jobs.present? %>
<%= render partial: '/shared/job_item', collection: @latest_jobs %>
<% end %>
</ul>
<%= link_to jobs_path, class: "load_more_jobs" do %>
......@@ -95,12 +66,7 @@
Here we list our cities and how many people we’ve helped find a job and companies have found recruits. It's a pretty awesome stats area!
</p>
<ul class="job-stats row showing-4">
<% @latest_cities.each do |city| %>
<li class="job-stat col-md-3 col-sm-6 col-xs-12">
<strong><%= city.jobs.count %></strong>
<%= link_to city.title, jobs_with_city_path(city_id: city.id) %>
</li>
<% end %>
<%= render partial: '/shared/latest_industry', collection: @latest_cities %>
</ul>
<%= link_to cities_path, class: "load_more_jobs" do %>
<strong>Load more listings</strong>
......@@ -128,12 +94,7 @@
<div class="container">
<h3 class="widget-title widget-title--home">Top Industries</h3>
<ul class="job-stats row showing-4">
<% @latest_industries.each do |industry| %>
<li class="job-stat col-md-3 col-sm-6 col-xs-12">
<strong><%= industry.jobs.count %></strong>
<%= link_to industry.title, jobs_with_industry_path(industry_id: industry.id) %>
</li>
<% end %>
<%= render partial: '/shared/latest_industry', collection: @latest_industries %>
</ul>
<%= link_to industries_path, class: "load_more_jobs" do %>
<strong>Load more listings</strong>
......
......@@ -27,38 +27,7 @@
<noscript>Your browser does not support JavaScript, or it is disabled. JavaScript must be enabled in order to view listings.</noscript>
<% if @jobs.present? %>
<ul class="job_listings">
<% @jobs.each do |job| %>
<li class="job_listing job-type-part-time post-3354 type-job_listing status-publish has-post-thumbnail hentry job_listing_category-design job_listing_type-part-time">
<div class="job_listing-logo">
<%= link_to(job) do %>
<img class="company_logo" src="<%= job.company.logo != "" ? job.company.logo : "https://via.placeholder.com/66x38?text=Logo" %>" alt="<%= job.company.title %>">
<% end %>
</div>
<div class="job_listing-about">
<div class="job_listing-position job_listing__column">
<h3 class="job_listing-title">
<%= link_to job.title, job %>
</h3>
<div class="job_listing-company">
<strong>
<%= link_to job.company.title, jobs_with_company_path(company_id: job.company.id) %>
</strong>
</div>
</div>
<div class="job_listing-location job_listing__column">
<% job.cities.each_with_index do |city, index| %>
<%= link_to jobs_with_city_path(city_id: city.id), class: "google_map_link" do %>
<%= city.title %><%= ", " if index != job.cities.size - 1 %>
<% end %>
<% end %>
</div>
<ul class="job_listing-meta job_listing__column">
<li class="job_listing-type job-type part-time"><%= job.salary %></li>
<li class="job_listing-date"><%= job.expiration_date %></li>
</ul>
</div>
</li>
<% end %>
<%= render partial: '/shared/job_item', collection: @jobs %>
</ul>
<div class="job-manager-pagination">
<%= paginate @jobs %>
......
......@@ -10,11 +10,11 @@
<div class="container content-area">
<div class="entry-content">
<div class="job_listings">
<%= form_tag(search_jobs_path, :method => "get", :class => "job_filters") do %>
<%= form_tag(search_jobs_path, :method => "get") do %>
<div class="search_jobs">
<div class="search_keywords">
<label for="keyword">Keywords</label>
<input type="text" name="keyword" id="keyword" placeholder="Keywords" value="<%= params[:keyword]%>" />
<input type="search" name="keyword" id="keyword" placeholder="Keywords" value="<%= params[:keyword]%>" />
</div>
<div class="search_submit">
<%= submit_tag "Search Jobs", name: nil %>
......@@ -24,7 +24,6 @@
<span>Search completed. Found <%= @amount_job %> matching records.</span>
</div>
<% end %>
<noscript>Your browser does not support JavaScript, or it is disabled. JavaScript must be enabled in order to view listings.</noscript>
<% if @jobs.present? %>
<ul class="job_listings">
<% @jobs.each do |job| %>
......
......@@ -42,14 +42,14 @@
</aside>
<aside class="widget widget--job_listing">
<div class="job_application application" style="margin-bottom: 15px;">
<% unless @apply.present? %>
<% if @apply.blank? %>
<input type="button" class="application_button button apply-or-favorite-jobs" value="Apply for job" data-id="<%= @job.id %>" data-type="apply"/>
<% else %>
<input type="button" class="application_button button" value="Apply for job" disabled/>
<% end %>
</div>
<div class="job_application application">
<% unless @favorite.present? %>
<% if @favorite.blank? %>
<input type="button" class="application_button button apply-or-favorite-jobs" value="Favorite" data-id="<%= @job.id %>" data-type="favorite"/>
<% else %>
<input type="button" class="application_button button" value="Favorite" disabled/>
......@@ -61,7 +61,7 @@
<ul>
<li>Name: <%= @job.company.title %></li>
<li>Address: <%= @job.company.address %></li>
<li>Description: <%= raw(@job.company.description) %></li>
<%= raw(@job.company.description) %>
</ul>
</aside>
<aside class="widget widget--job_listing">
......@@ -78,37 +78,8 @@
<div class="related-jobs container">
<h3 class="widget-title widget--title-job_listing-top">Related Jobs</h3>
<ul class="job_listings related">
<% @relate_jobs.each do |job| %>
<li class="job_listing job-type-part-time post-3354 type-job_listing status-publish has-post-thumbnail hentry job_listing_category-design job_listing_type-part-time">
<div class="job_listing-logo">
<%= link_to(job) do %>
<img class="company_logo" src="<%= job.company.logo != "" ? job.company.logo : "https://via.placeholder.com/66x38?text=Logo" %>" alt="<%= job.company.title %>" />
<% end %>
</div>
<div class="job_listing-about">
<div class="job_listing-position job_listing__column">
<h3 class="job_listing-title">
<%= link_to job.title, job %>
</h3>
<div class="job_listing-company">
<strong>
<%= link_to job.company.title, jobs_with_company_path(company_id: job.company.id) %>
</strong>
</div>
</div>
<div class="job_listing-location job_listing__column">
<% job.cities.each_with_index do |city, index| %>
<%= link_to jobs_with_city_path(city_id: city.id), class: "google_map_link" do %>
<%= city.title %><%= ", " if index != job.cities.size - 1 %>
<% end %>
<% end %>
</div>
<ul class="job_listing-meta job_listing__column">
<li class="job_listing-type job-type part-time"><%= job.salary %></li>
<li class="job_listing-date"><%= job.expiration_date %></li>
</ul>
</div>
</li>
<% if @relate_jobs.present? %>
<%= render partial: '/shared/job_item', collection: @relate_jobs %>
<% end %>
</ul>
</div>
......
<% set_meta_tags title: "VenJob - 404",
description: "VenJob - 404",
keywords: "VenJob - 404" %>
<header class="page-header">
<h2 class="page-title">Page Not Found</h2>
</header>
<div id="primary" class="content-area container" role="main">
<div class="blog-archive">
<div class="content-none">
<p>It seems we can’t find what you’re looking for</p>
</div>
</div>
</div>
\ No newline at end of file
<tr class="woocommerce-cart-form__cart-item cart_item">
<td>
<%= history_item_counter + 1 %>
</td>
<td style="text-align: center;">
<input type="checkbox" class="checkbox-apply-job" data-id="<%= history_item.id %>">
</td>
<td>
<%= link_to history_item.title, history_item %>
</td>
<td>
<% history_item.cities.each_with_index do |city, index| %>
<%= city.title %><%= ", " if index != history_item.cities.size - 1 %>
<% end %>
</td>
<td class="product-price">
<%= history_item.salary %>
</td>
</tr>
\ No newline at end of file
<tr class="woocommerce-cart-form__cart-item cart_item">
<td>
<%= history_item_counter + 1 %>
</td>
<td style="text-align: center;">
<input type="checkbox" class="checkbox-apply-job" data-id="<%= history_item.job_id %>">
</td>
<td>
<%= link_to history_item.job.title, history_item.job %>
</td>
<td>
<% history_item.job.cities.each_with_index do |city, index| %>
<%= city.title %><%= ", " if index != history_item.job.cities.size - 1 %>
<% end %>
</td>
<td class="product-price">
<%= history_item.job.salary %>
</td>
</tr>
\ No newline at end of file
<li class="job_listing job-type-part-time post-3354 type-job_listing status-publish has-post-thumbnail hentry job_listing_category-design job_listing_type-part-time">
<div class="job_listing-logo">
<%= link_to(job_item) do %>
<img class="company_logo" src="<%= job_item.company.logo != "" ? job_item.company.logo : "https://via.placeholder.com/66x38?text=Logo" %>" alt="<%= job_item.company.title %>">
<% end %>
</div>
<div class="job_listing-about">
<div class="job_listing-position job_listing__column">
<h3 class="job_listing-title">
<%= link_to job_item.title, job_item %>
</h3>
<div class="job_listing-company">
<strong>
<%= link_to job_item.company.title, jobs_with_company_path(company_id: job_item.company.id) %>
</strong>
</div>
</div>
<div class="job_listing-location job_listing__column">
<% job_item.cities.each_with_index do |city, index| %>
<%= link_to jobs_with_city_path(city_id: city.id), class: "google_map_link" do %>
<%= city.title %><%= ", " if index != job_item.cities.size - 1 %>
<% end %>
<% end %>
</div>
<ul class="job_listing-meta job_listing__column">
<li class="job_listing-type job-type part-time"><%= job_item.salary %></li>
<li class="job_listing-date"><%= job_item.expiration_date %></li>
</ul>
</div>
</li>
\ No newline at end of file
<li class="job-stat col-md-3 col-sm-6 col-xs-12">
<strong><%= latest_city.jobs_count %></strong>
<%= link_to latest_city.title, jobs_with_city_path(city_id: latest_city.id) %>
</li>
\ No newline at end of file
<li class="job-stat col-md-3 col-sm-6 col-xs-12">
<strong><%= latest_industry.jobs_count %></strong>
<%= link_to latest_industry.title, jobs_with_industry_path(industry_id: latest_industry.id) %>
</li>
\ No newline at end of file
<% content_for :title, "VenJob - Appied Jobs" %>
<% set_meta_tags title: "VenJob - Applied Jobs",
description: "VenJob - Applied Jobs",
keywords: "VenJob - Applied Jobs" %>
<header class="page-header">
<h2 class="page-title">Appied Jobs</h2>
<h2 class="page-title">Applied Jobs</h2>
</header>
<div id="primary" class="content-area container" role="main">
<article id="post-1673" class="post-1673 page type-page status-publish hentry">
......
<%= content_for :title, "VenJob - Favorite jobs" %>
<% set_meta_tags title: "VenJob - Favorite Jobs",
description: "VenJob - Favorite Jobs",
keywords: "VenJob - Favorite Jobs" %>
<header class="page-header">
<h2 class="page-title">Favorite jobs</h2>
</header>
......
<% content_for :title, "VenJob - User info" %>
<% set_meta_tags title: "VenJob - User information",
description: "VenJob - User information",
keywords: "VenJob - User information" %>
<header class="page-header">
<h2 class="page-title">User info</h2>
<h2 class="page-title">User information</h2>
</header>
<div id="primary" class="content-area container" role="main">
<article id="post-1673" class="post-1673 page type-page status-publish hentry">
......
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'
#!/usr/bin/env ruby
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError => e
raise unless e.message.include?('spring')
end
require_relative '../config/boot'
require 'rake'
Rake.application.run
......@@ -7,7 +7,7 @@ Rails.application.configure do
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
config.eager_load = true
# Show full error reports.
config.consider_all_requests_local = true
......@@ -59,8 +59,4 @@ Rails.application.configure do
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {:address => "localhost", :port => 1025}
end
......@@ -7,6 +7,7 @@ Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
config.cache_classes = false
config.action_view.cache_template_loading = true
# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
......
# Be sure to restart your server when you modify this file.
#
# This file contains migration options to ease your Rails 6.0 upgrade.
#
# Once upgraded flip defaults one by one to migrate to the new default.
#
# Read the Guide for Upgrading Ruby on Rails for more info on each option.
# Don't force requests from old versions of IE to be UTF-8 encoded.
# Rails.application.config.action_view.default_enforce_utf8 = false
# Embed purpose and expiry metadata inside signed and encrypted
# cookies for increased security.
#
# This option is not backwards compatible with earlier Rails versions.
# It's best enabled when your entire app is migrated and stable on 6.0.
# Rails.application.config.action_dispatch.use_cookies_with_metadata = true
# Change the return value of `ActionDispatch::Response#content_type` to Content-Type header without modification.
# Rails.application.config.action_dispatch.return_only_media_type_on_content_type = false
# Return false instead of self when enqueuing is aborted from a callback.
# Rails.application.config.active_job.return_false_on_aborted_enqueue = true
# Send Active Storage analysis and purge jobs to dedicated queues.
# Rails.application.config.active_storage.queues.analysis = :active_storage_analysis
# Rails.application.config.active_storage.queues.purge = :active_storage_purge
# When assigning to a collection of attachments declared via `has_many_attached`, replace existing
# attachments instead of appending. Use #attach to add new attachments without replacing existing ones.
# Rails.application.config.active_storage.replace_on_assign_to_many = true
# Use ActionMailer::MailDeliveryJob for sending parameterized and normal mail.
#
# The default delivery jobs (ActionMailer::Parameterized::DeliveryJob, ActionMailer::DeliveryJob),
# will be removed in Rails 6.1. This setting is not backwards compatible with earlier Rails versions.
# If you send mail in the background, job workers need to have a copy of
# MailDeliveryJob to ensure all delivery jobs are processed properly.
# Make sure your entire app is migrated and stable on 6.0 before using this setting.
# Rails.application.config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob"
# Enable the same cache key to be reused when the object being cached of type
# `ActiveRecord::Relation` changes by moving the volatile information (max updated at and count)
# of the relation's cache key into the cache version to support recycling cache key.
# Rails.application.config.active_record.collection_cache_versioning = true
......@@ -31,10 +31,3 @@
en:
hello: "Hello world"
header_csv:
title: Title
updated_date_job: Updated date job
level: Level
years_of_experience: Years of experience
salary: Salary
expiration_date: Expiration date
\ No newline at end of file
......@@ -23,6 +23,7 @@ Rails.application.routes.draw do
get '/users/applied-jobs', to: 'users#apply_jobs'
get '/users/favorite-jobs', to: 'users#favorite_jobs'
get '/admins/applies', to: 'admins#applies', as: 'admins_applies'
get '/pages/404', to: 'pages#page_404', as: 'page_404'
post '/apply_or_favorite', to: 'users#apply_or_favorite_jobs'
......
# This migration comes from active_storage (originally 20180723000244)
class AddForeignKeyConstraintToActiveStorageAttachmentsForBlobId < ActiveRecord::Migration[6.0]
def up
return if foreign_key_exists?(:active_storage_attachments, column: :blob_id)
if table_exists?(:active_storage_blobs)
add_foreign_key :active_storage_attachments, :active_storage_blobs, column: :blob_id
end
end
end
class CreateHistories < ActiveRecord::Migration[6.0]
def change
create_table :histories do |t|
t.references :user, null: false, foreign_key: true
t.references :job, null: false, foreign_key: true
t.timestamps
end
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_05_15_033747) do
ActiveRecord::Schema.define(version: 2020_05_19_030913) do
create_table "admins", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
t.string "email", default: "", null: false
......@@ -65,6 +65,15 @@ ActiveRecord::Schema.define(version: 2020_05_15_033747) do
t.index ["user_id"], name: "index_favorites_on_user_id"
end
create_table "histories", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
t.bigint "user_id", null: false
t.bigint "job_id", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["job_id"], name: "index_histories_on_job_id"
t.index ["user_id"], name: "index_histories_on_user_id"
end
create_table "industries", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
t.string "title"
t.datetime "created_at", precision: 6, null: false
......@@ -122,4 +131,6 @@ ActiveRecord::Schema.define(version: 2020_05_15_033747) do
add_foreign_key "applies", "users"
add_foreign_key "favorites", "jobs"
add_foreign_key "favorites", "users"
add_foreign_key "histories", "jobs"
add_foreign_key "histories", "users"
end
......@@ -3,63 +3,44 @@ namespace :solr do
desc "Solr management"
solr_job = RSolr.connect :url => "http://localhost:8983/solr/job"
solr_apply = RSolr.connect :url => "http://localhost:8983/solr/apply"
task import_job: :environment do
jobs = Job.all
hash_jobs = jobs.map { |item|
{
apply_count: Apply.where("job_id = ?", item.id).count,
city_ids: item.cities.map { |city| city.id },
city_names: item.cities.map { |city| city.title },
hash_jobs = []
Job.find_each do |item|
job = {
apply_count: item.applies.size,
city_ids: item.cities.pluck(:id),
city_names: item.cities.pluck(:title),
company_id: item.company_id,
company_name: item.company.title,
company_address: item.company.address,
company_description: item.company.description,
company_logo: item.company.logo,
created_at: item.created_at.to_i,
expiration_date: item.expiration_date.nil? ? 0 : DateTime.parse(item.expiration_date).to_i,
favorite_count: Favorite.where("job_id = ?", item.id).count,
industry_ids: item.industries.map { |industry| industry.id },
industry_names: item.industries.map { |industry| industry.title },
expiration_date: DateTime.parse(item.expiration_date).to_i,
favorite_count: item.favorites.size,
industry_ids: item.industries.pluck(:id),
industry_names: item.industries.pluck(:title),
job_description: item.job_description,
job_benefit: item.benefit,
job_id: item.id,
job_other_information: item.other_information,
job_requirements: item.job_requirements,
job_title: item.title,
level: item.level,
max_salary: item.max_salary,
min_salary: item.min_salary,
salary: item.salary,
updated_date_job: item.updated_date_job.nil? ? 0 : DateTime.parse(item.updated_date_job).to_i,
updated_date_job: DateTime.parse(item.updated_date_job).to_i,
years_of_experience: item.years_of_experience
}
}
hash_jobs << job
end
solr_job.add hash_jobs
solr_job.commit
end
task import_apply: :environment do
applies = Apply.all
hash_applies = applies.map { |item|
{
apply_id: item.id,
job_id: item.job.id,
job_title: item.job.title,
industry_ids: item.job.industries.map { |industry| industry.id },
industry_names: item.job.industries.map { |industry| industry.title },
city_ids: item.job.cities.map { |city| city.id },
city_names: item.job.cities.map { |city| city.title },
user_full_name: item.user.full_name,
user_email: item.user.email,
user_cv: item.user.cv.nil? ? "" : item.user.cv.to_s,
applied_at: item.created_at.to_i,
}
}
solr_apply.add hash_applies
solr_apply.commit
end
task delete_all_job: :environment do
solr_job.delete_by_query "*:*"
solr_job.commit
end
task delete_all_apply: :environment do
solr_apply.delete_by_query "*:*"
solr_apply.commit
end
end
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