Commit 8e3505d4 by Hoang Phuc

Admin applied query Solr

parent 6ecd3747
Pipeline #596 failed with stages
in 0 seconds
...@@ -31,6 +31,8 @@ gem 'carrierwave' ...@@ -31,6 +31,8 @@ gem 'carrierwave'
gem 'activerecord-import' gem 'activerecord-import'
gem 'will_paginate'
gem 'settingslogic' gem 'settingslogic'
# Use Active Storage variant # Use Active Storage variant
# gem 'image_processing', '~> 1.2' # gem 'image_processing', '~> 1.2'
......
...@@ -278,6 +278,7 @@ GEM ...@@ -278,6 +278,7 @@ GEM
websocket-driver (0.7.1-java) websocket-driver (0.7.1-java)
websocket-extensions (>= 0.1.0) websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.4) websocket-extensions (0.1.4)
will_paginate (3.3.0)
xpath (3.2.0) xpath (3.2.0)
nokogiri (~> 1.8) nokogiri (~> 1.8)
zeitwerk (2.3.0) zeitwerk (2.3.0)
...@@ -315,6 +316,7 @@ DEPENDENCIES ...@@ -315,6 +316,7 @@ DEPENDENCIES
web-console (>= 3.3.0) web-console (>= 3.3.0)
webdrivers webdrivers
webpacker (~> 4.0) webpacker (~> 4.0)
will_paginate
RUBY VERSION RUBY VERSION
ruby 2.7.0p0 ruby 2.7.0p0
......
...@@ -1946,6 +1946,7 @@ input[type=password], ...@@ -1946,6 +1946,7 @@ input[type=password],
input[type=search], input[type=search],
input[type=tel], input[type=tel],
input[type=text], input[type=text],
input[type=date],
select, select,
textarea { textarea {
font-size: 16px; font-size: 16px;
......
...@@ -186,7 +186,7 @@ body { ...@@ -186,7 +186,7 @@ body {
line-height: 1.3; line-height: 1.3;
} }
.entry-content .rcp_form input[type=email], .entry-content .rcp_form input[type=password], .entry-content .rcp_form input[type=text], .jobify-input, input[type=email], input[type=number], input[type=password], input[type=search], input[type=tel], input[type=text], select, textarea, body .chosen-container-single .chosen-single span, body .chosen-container .chosen-results li.active-result { .entry-content .rcp_form input[type=email], .entry-content .rcp_form input[type=password], .entry-content .rcp_form input[type=text], .jobify-input, input[type=email], input[type=number], input[type=password], input[type=search], input[type=date], input[type=tel], input[type=text], select, textarea, body .chosen-container-single .chosen-single span, body .chosen-container .chosen-results li.active-result {
font-family: "Varela Round", "Helvetica Neue", Helvetica, Arial, sans-serif; font-family: "Varela Round", "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: normal; font-weight: normal;
line-height: 1; line-height: 1;
...@@ -369,6 +369,9 @@ nav.pagination span a, nav.pagination span.current{ ...@@ -369,6 +369,9 @@ nav.pagination span a, nav.pagination span.current{
nav.pagination span.current{ nav.pagination span.current{
color: #7dc246; color: #7dc246;
} }
.wp-job-manager-categories-enabled .search_jobs div.search_keywords{
width: 73%;
}
@media screen and (min-width: 1200px) { @media screen and (min-width: 1200px) {
.job_listing-about, .resume-about { .job_listing-about, .resume-about {
width: 90%; width: 90%;
......
...@@ -86,5 +86,4 @@ ...@@ -86,5 +86,4 @@
}); });
} }
}) })
})(jQuery); })(jQuery);
\ No newline at end of file
# frozen_string_literal: true
class Admins::ConfirmationsController < Devise::ConfirmationsController
# GET /resource/confirmation/new
# def new
# super
# end
# POST /resource/confirmation
# def create
# super
# end
# GET /resource/confirmation?confirmation_token=abcdef
# def show
# super
# end
# protected
# The path used after resending confirmation instructions.
# def after_resending_confirmation_instructions_path_for(resource_name)
# super(resource_name)
# end
# The path used after confirmation.
# def after_confirmation_path_for(resource_name, resource)
# super(resource_name, resource)
# end
end
# frozen_string_literal: true
class Admins::OmniauthCallbacksController < Devise::OmniauthCallbacksController
# You should configure your model like this:
# devise :omniauthable, omniauth_providers: [:twitter]
# You should also create an action method in this controller like this:
# def twitter
# end
# More info at:
# https://github.com/plataformatec/devise#omniauth
# GET|POST /resource/auth/twitter
# def passthru
# super
# end
# GET|POST /users/auth/twitter/callback
# def failure
# super
# end
# protected
# The path used when OmniAuth fails
# def after_omniauth_failure_path_for(scope)
# super(scope)
# end
end
# frozen_string_literal: true
class Admins::PasswordsController < Devise::PasswordsController
# GET /resource/password/new
# def new
# super
# end
# POST /resource/password
# def create
# super
# end
# GET /resource/password/edit?reset_password_token=abcdef
# def edit
# super
# end
# PUT /resource/password
# def update
# super
# end
# protected
# def after_resetting_password_path_for(resource)
# super(resource)
# end
# The path used after sending reset password instructions
# def after_sending_reset_password_instructions_path_for(resource_name)
# super(resource_name)
# end
end
# frozen_string_literal: true
class Admins::RegistrationsController < Devise::RegistrationsController
# before_action :configure_sign_up_params, only: [:create]
# before_action :configure_account_update_params, only: [:update]
# GET /resource/sign_up
# def new
# super
# end
# POST /resource
# def create
# super
# end
# GET /resource/edit
# def edit
# super
# end
# PUT /resource
# def update
# super
# end
# DELETE /resource
# def destroy
# super
# end
# GET /resource/cancel
# Forces the session data which is usually expired after sign
# in to be expired now. This is useful if the user wants to
# cancel oauth signing in/up in the middle of the process,
# removing all OAuth session data.
# def cancel
# super
# end
# protected
# If you have extra params to permit, append them to the sanitizer.
# def configure_sign_up_params
# devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])
# end
# If you have extra params to permit, append them to the sanitizer.
# def configure_account_update_params
# devise_parameter_sanitizer.permit(:account_update, keys: [:attribute])
# end
# The path used after sign up.
# def after_sign_up_path_for(resource)
# super(resource)
# end
# The path used after sign up for inactive accounts.
# def after_inactive_sign_up_path_for(resource)
# super(resource)
# end
end
# frozen_string_literal: true
class Admins::SessionsController < Devise::SessionsController
# before_action :configure_sign_in_params, only: [:create]
# GET /resource/sign_in
# def new
# super
# end
# POST /resource/sign_in
# def create
# super
# end
# DELETE /resource/sign_out
# def destroy
# super
# end
# protected
# If you have extra params to permit, append them to the sanitizer.
# def configure_sign_in_params
# devise_parameter_sanitizer.permit(:sign_in, keys: [:attribute])
# end
end
# frozen_string_literal: true
class Admins::UnlocksController < Devise::UnlocksController
# GET /resource/unlock/new
# def new
# super
# end
# POST /resource/unlock
# def create
# super
# end
# GET /resource/unlock?unlock_token=abcdef
# def show
# super
# end
# protected
# The path used after sending unlock password instructions
# def after_sending_unlock_instructions_path_for(resource)
# super(resource)
# end
# The path used after unlocking the resource
# def after_unlock_path_for(resource)
# super(resource)
# end
end
class AdminsController < ApplicationController
def applies
@cities = City.order("title ASC").all
@industries = Industry.order("title ASC").all
query_params = "*"
if params[:user_email] && params[:user_email] != ""
query_params << "AND user_email:#{params[:user_email]}"
end
if params[:city_ids] && params[:city_ids] != ""
query_params << "AND city_ids:#{params[:city_ids]}"
end
if params[:industry_ids] && params[:industry_ids] != ""
query_params << "AND industry_ids:#{params[:industry_ids]}"
end
if params[:applied_at_from] && params[:applied_at_from] != "" && params[:applied_at_to] && params[:applied_at_to] == ""
query_params << "AND applied_at:[#{params[:applied_at_from].to_time.to_i} TO *]"
elsif params[:applied_at_from] && params[:applied_at_from] != "" && params[:applied_at_to] && params[:applied_at_to] != ""
query_params << "AND applied_at:[#{params[:applied_at_from].to_time.to_i} TO #{params[:applied_at_to].to_time.to_i}]"
end
response = solr_apply.paginate params[:page], 5, "select", :params => {
:q=>query_params
}
@applies = response["response"]["docs"]
end
end
require "rsolr"
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller? before_action :configure_permitted_parameters, if: :devise_controller?
before_action :solr_job
before_action :solr_apply
protected protected
def configure_permitted_parameters def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:full_name]) devise_parameter_sanitizer.permit(:sign_up, keys: [:full_name])
devise_parameter_sanitizer.permit(:account_update, keys: [:full_name, :cv]) devise_parameter_sanitizer.permit(:account_update, keys: [:full_name, :cv])
end end
def solr_job
solr_job = RSolr.connect :url => "http://localhost:8983/solr/job"
end
def solr_apply
solr_apply = RSolr.connect :url => "http://localhost:8983/solr/apply"
end
end end
class HistoryController < ApplicationController class HistoryController < ApplicationController
def index def index
if cookies[:job_ids_history].nil? if cookies[:job_ids_history].nil?
redirect_to '/jobs' redirect_to "/jobs"
else else
arr_job_ids = cookies[:job_ids_history].split(",") arr_job_ids = cookies[:job_ids_history].split(",")
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.where("id IN (?)", job_ids).order("id DESC")
end end
end end
end end
\ No newline at end of file
...@@ -39,4 +39,15 @@ class JobsController < ApplicationController ...@@ -39,4 +39,15 @@ class JobsController < ApplicationController
@title = "Job was not found" @title = "Job was not found"
end end
end end
def search
unless params[:keyword].nil?
response = solr_job.paginate params[:page], 25, "select", :params => {
:q=>"job_title:#{params[:keyword]}"
}
@jobs = response["response"]["docs"]
@amount_job = response["response"]["numFound"]
else
redirect_to "/"
end
end
end end
# frozen_string_literal: true
class Users::ConfirmationsController < Devise::ConfirmationsController
# GET /resource/confirmation/new
# def new
# super
# end
# POST /resource/confirmation
# def create
# super
# end
# GET /resource/confirmation?confirmation_token=abcdef
# def show
# super
# end
# protected
# The path used after resending confirmation instructions.
# def after_resending_confirmation_instructions_path_for(resource_name)
# super(resource_name)
# end
# The path used after confirmation.
# def after_confirmation_path_for(resource_name, resource)
# super(resource_name, resource)
# end
end
# frozen_string_literal: true
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
# You should configure your model like this:
# devise :omniauthable, omniauth_providers: [:twitter]
# You should also create an action method in this controller like this:
# def twitter
# end
# More info at:
# https://github.com/plataformatec/devise#omniauth
# GET|POST /resource/auth/twitter
# def passthru
# super
# end
# GET|POST /users/auth/twitter/callback
# def failure
# super
# end
# protected
# The path used when OmniAuth fails
# def after_omniauth_failure_path_for(scope)
# super(scope)
# end
end
# frozen_string_literal: true
class Users::PasswordsController < Devise::PasswordsController
# GET /resource/password/new
# def new
# super
# end
# POST /resource/password
# def create
# super
# end
# GET /resource/password/edit?reset_password_token=abcdef
# def edit
# super
# end
# PUT /resource/password
# def update
# super
# end
# protected
# def after_resetting_password_path_for(resource)
# super(resource)
# end
# The path used after sending reset password instructions
# def after_sending_reset_password_instructions_path_for(resource_name)
# super(resource_name)
# end
end
# frozen_string_literal: true
class Users::RegistrationsController < Devise::RegistrationsController
# before_action :configure_sign_up_params, only: [:create]
# before_action :configure_account_update_params, only: [:update]
# GET /resource/sign_up
# def new
# super
# end
# POST /resource
# def create
# super
# end
# GET /resource/edit
# def edit
# super
# end
# PUT /resource
# def update
# super
# end
# DELETE /resource
# def destroy
# super
# end
# GET /resource/cancel
# Forces the session data which is usually expired after sign
# in to be expired now. This is useful if the user wants to
# cancel oauth signing in/up in the middle of the process,
# removing all OAuth session data.
# def cancel
# super
# end
# protected
# If you have extra params to permit, append them to the sanitizer.
# def configure_sign_up_params
# devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])
# end
# If you have extra params to permit, append them to the sanitizer.
# def configure_account_update_params
# devise_parameter_sanitizer.permit(:account_update, keys: [:attribute])
# end
# The path used after sign up.
# def after_sign_up_path_for(resource)
# super(resource)
# end
# The path used after sign up for inactive accounts.
# def after_inactive_sign_up_path_for(resource)
# super(resource)
# end
end
# frozen_string_literal: true
class Users::SessionsController < Devise::SessionsController
# before_action :configure_sign_in_params, only: [:create]
# GET /resource/sign_in
# def new
# super
# end
# POST /resource/sign_in
# def create
# super
# end
# DELETE /resource/sign_out
# def destroy
# super
# end
# protected
# If you have extra params to permit, append them to the sanitizer.
# def configure_sign_in_params
# devise_parameter_sanitizer.permit(:sign_in, keys: [:attribute])
# end
end
# frozen_string_literal: true
class Users::UnlocksController < Devise::UnlocksController
# GET /resource/unlock/new
# def new
# super
# end
# POST /resource/unlock
# def create
# super
# end
# GET /resource/unlock?unlock_token=abcdef
# def show
# super
# end
# protected
# The path used after sending unlock password instructions
# def after_sending_unlock_instructions_path_for(resource)
# super(resource)
# end
# The path used after unlocking the resource
# def after_unlock_path_for(resource)
# super(resource)
# end
end
class UsersController < ApplicationController class UsersController < ApplicationController
def info def info
unless user_signed_in? unless user_signed_in?
redirect_to '/users/sign_in' redirect_to "/users/sign_in"
end end
end end
def apply_jobs def apply_jobs
unless user_signed_in? unless user_signed_in?
redirect_to '/users/sign_in' redirect_to "/users/sign_in"
else else
@applied_jobs = Apply.where("user_id = ?", current_user.id) @applied_jobs = Apply.where("user_id = ?", current_user.id)
end end
end end
def favorite_jobs def favorite_jobs
unless user_signed_in? unless user_signed_in?
redirect_to '/users/sign_in' redirect_to "/users/sign_in"
else else
@favorite_jobs = Favorite.where("user_id = ?", current_user.id) @favorite_jobs = Favorite.where("user_id = ?", current_user.id)
end end
......
<%= content_for :title, "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">
<article id="post-14" class="post-14 page type-page status-publish hentry">
<div class="entry-content">
<%= form_tag(admins_applies_path, :method => "get", :class => "job-manager-form") do %>
<fieldset class="fieldset-job_title fieldset-type-text">
<label for="user_email">User email</label>
<div class="field required-field">
<input type="text" class="input-text" name="user_email" id="user_email" placeholder="User email" value="<%= params[:user_email] %>">
</div>
</fieldset>
<div class="row">
<div class="col-md-6">
<fieldset class="fieldset-job_type fieldset-type-term-select">
<label for="city_ids">City</label>
<div class="field required-field">
<span class="select postform-wrapper">
<select name="city_ids" id="city_ids" class="postform">
<option value="">Select</option>
<% @cities.each do |city| %>
<option class="level-0" value="<%= city.id %>"><%= city.title %></option>
<% end %>
</select>
</span>
</div>
</fieldset>
</div>
<div class="col-md-6">
<fieldset class="fieldset-job_type fieldset-type-term-select">
<label for="industry_ids">Industry</label>
<div class="field required-field">
<span class="select postform-wrapper">
<select name="industry_ids" id="industry_ids" class="postform">
<option selected value="">Select</option>
<% @industries.each do |industry| %>
<option class="level-0" value="<%= industry.id %>"><%= industry.title %></option>
<% end %>
</select>
</span>
</div>
</fieldset>
</div>
</div>
<div class="row">
<div class="col-md-6">
<fieldset class="fieldset-job_title fieldset-type-text">
<label for="applied_at_from">Applied at from</label>
<input type="date" class="input-text" name="applied_at_from" id="applied_at_from">
</fieldset>
</div>
<div class="col-md-6">
<fieldset class="fieldset-job_title fieldset-type-text">
<label for="applied_at_to">to</label>
<input type="date" class="input-text" name="applied_at_to" id="applied_at_to">
</fieldset>
</div>
</div>
<p>
<%= submit_tag "Search", name: nil, class: "button" %>
<input type="submit" name="save_draft" class="button secondary save_draft" value="CSV Download" style="float: right;">
</p>
<% end %>
<div class="clearfix"></div>
<table class="table" style="word-break: break-all;">
<thead>
<tr>
<th width="50px">ID</th>
<th width="200px">Job title</th>
<th width="150px">Full name</th>
<th width="200px">Email</th>
<th width="200px">CV</th>
<th>Applied at</th>
</tr>
</thead>
<tbody>
<% @applies.each do |apply| %>
<tr>
<th><%= apply["apply_id"] %></th>
<td><%= apply["job_title"] %></td>
<td><%= apply["user_full_name"] %></td>
<td><%= apply["user_email"] %></td>
<td><%= apply["user_cv"].split("/").last %></td>
<td><%= apply["applied_at"] > 0 ? Time.at(apply["applied_at"]).to_date.to_s : "" %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="job-manager-pagination">
<%= will_paginate @applies %>
</div>
</div>
</article>
<!-- #post -->
</div>
</div>
</div>
\ No newline at end of file
<h2>Resend confirmation instructions</h2>
<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, autocomplete: "email", value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
</div>
<div class="actions">
<%= f.submit "Resend confirmation instructions" %>
</div>
<% end %>
<%= render "admins/shared/links" %>
<p>Welcome <%= @email %>!</p>
<p>You can confirm your account email through the link below:</p>
<p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p>
<p>Hello <%= @email %>!</p>
<% if @resource.try(:unconfirmed_email?) %>
<p>We're contacting you to notify you that your email is being changed to <%= @resource.unconfirmed_email %>.</p>
<% else %>
<p>We're contacting you to notify you that your email has been changed to <%= @resource.email %>.</p>
<% end %>
<p>Hello <%= @resource.email %>!</p>
<p>We're contacting you to notify you that your password has been changed.</p>
<p>Hello <%= @resource.email %>!</p>
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
<p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>
<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
<p>Hello <%= @resource.email %>!</p>
<p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p>
<p>Click the link below to unlock your account:</p>
<p><%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %></p>
<h2>Change your password</h2>
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<%= f.hidden_field :reset_password_token %>
<div class="field">
<%= f.label :password, "New password" %><br />
<% if @minimum_password_length %>
<em>(<%= @minimum_password_length %> characters minimum)</em><br />
<% end %>
<%= f.password_field :password, autofocus: true, autocomplete: "new-password" %>
</div>
<div class="field">
<%= f.label :password_confirmation, "Confirm new password" %><br />
<%= f.password_field :password_confirmation, autocomplete: "new-password" %>
</div>
<div class="actions">
<%= f.submit "Change my password" %>
</div>
<% end %>
<%= render "admins/shared/links" %>
<h2>Forgot your password?</h2>
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
</div>
<div class="actions">
<%= f.submit "Send me reset password instructions" %>
</div>
<% end %>
<%= render "admins/shared/links" %>
<% content_for :title, "VenJob - Edit Admin #{resource_name.to_s.humanize}" %>
<header class="page-header">
<h2 class="page-title">Edit Admin <%= resource_name.to_s.humanize %></h2>
</header>
<div id="primary" class="content-area container" role="main">
<article id="post-1673" class="post-1673 page type-page status-publish hentry">
<div class="entry-content">
<div class="registration-form woocommerce">
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<p class="field">
<%= f.label :email %><br />
<%= f.email_field :email, placeholder: "Email" %>
</p>
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
<p>Currently waiting confirmation for: <%= resource.unconfirmed_email %></p>
<% end %>
<p class="field">
<%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
<%= f.password_field :password, autocomplete: "new-password", placeholder: "Password" %>
<% if @minimum_password_length %>
<br />
<em><%= @minimum_password_length %> characters minimum</em>
<% end %>
</p>
<p class="field">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "new-password", placeholder: "Confirm password" %>
</p>
<p class="field">
<%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
<%= f.password_field :current_password, autocomplete: "current-password", placeholder: "Current password" %>
</p>
<p class="actions" style="text-align: center;">
<%= f.submit "Update", class: "button" %>
</p>
<% end %>
</div>
</div>
</article>
</div>
\ No newline at end of file
<% content_for :title, "VenJob - Admins Sign Up" %>
<header class="page-header">
<h2 class="page-title">Admin Sign Up</h2>
</header>
<div id="primary" class="content-area container" role="main">
<article id="post-1673" class="post-1673 page type-page status-publish hentry">
<div class="entry-content">
<div class="registration-form woocommerce">
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<p class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autocomplete: "email" %>
</p>
<p class="field">
<%= f.label :password %>
<% if @minimum_password_length %>
<em>(<%= @minimum_password_length %> characters minimum)</em>
<% end %><br />
<%= f.password_field :password, autocomplete: "new-password" %>
</p>
<p class="field">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "new-password" %>
</p>
<p class="actions">
<%= f.submit "Sign up", class: "button" %>
</p>
<% end %>
<p>
Do you have account? <%= render "devise/shared/links" %>
</p>
</div>
</div>
</article>
</div>
\ No newline at end of file
<% content_for :title, "VenJob - Admin Sign In" %>
<header class="page-header">
<h2 class="page-title">Admin Sign In</h2>
</header>
<div id="primary" class="content-area container" role="main">
<article id="post-1673" class="post-1673 page type-page status-publish hentry">
<div class="entry-content">
<div class="registration-form woocommerce">
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
<p class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
</p>
<p class="field">
<%= f.label :password %><br />
<%= f.password_field :password, autocomplete: "current-password" %>
</p>
<% if devise_mapping.rememberable? %>
<p class="field">
<%= f.check_box :remember_me %>
<%= f.label :remember_me %>
</p>
<% end %>
<p class="actions">
<%= f.submit "Log in", class: "button" %>
</p>
<% end %>
<p>
<%= render "devise/shared/links" %>
</p>
</div>
</div>
</article>
</div>
\ No newline at end of file
<% if resource.errors.any? %>
<div id="error_explanation">
<h2>
<%= I18n.t("errors.messages.not_saved",
count: resource.errors.count,
resource: resource.class.model_name.human.downcase)
%>
</h2>
<ul>
<% resource.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<%- if controller_name != 'sessions' %>
<%= link_to "Log in", new_session_path(resource_name) %><br />
<% end %>
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
<% end %>
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
<% end %>
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
<% end %>
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
<% end %>
<%- if devise_mapping.omniauthable? %>
<%- resource_class.omniauth_providers.each do |provider| %>
<%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider) %><br />
<% end %>
<% end %>
<h2>Resend unlock instructions</h2>
<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
</div>
<div class="actions">
<%= f.submit "Resend unlock instructions" %>
</div>
<% end %>
<%= render "admins/shared/links" %>
...@@ -7,35 +7,17 @@ ...@@ -7,35 +7,17 @@
<h2 class="hero-search__title" style="color:#666666">The Easiest Way to Get Your New Job</h2> <h2 class="hero-search__title" style="color:#666666">The Easiest Way to Get Your New Job</h2>
<p>Find jobs, create trackable resumes and enrich your applications.</p> <p>Find jobs, create trackable resumes and enrich your applications.</p>
</div> </div>
<form class="job_search_form job_search_form--flat" action="https://jobify-demos.astoundify.com/classic/find-a-job/" method="GET"> <%= form_tag(search_jobs_path, :method => "get", :class => "job_search_form job_search_form--flat") do %>
<div class="search_jobs"> <div class="search_jobs">
<div class="search_keywords"> <div class="search_keywords">
<label for="search_keywords">Keywords</label> <label for="keyword">Keywords</label>
<input type="text" name="search_keywords" id="search_keywords" placeholder="Keywords" /> <input type="text" name="keyword" id="keyword" placeholder="Keywords" />
</div>
<div class="search_categories">
<label for="search_categories">Category</label>
<select name='search_categories[]' id='search_categories' class='job-manager-category-dropdown ' data-placeholder='Choose a category&hellip;' data-no_results_text='No results match' data-multiple_text='Select Some Options'>
<option value="">Any category</option>
<option class="level-0" value="17">Design</option>
<option class="level-0" value="18">Developement</option>
<option class="level-0" value="49">Marketing</option>
</select>
</div> </div>
<div class="search_submit"> <div class="search_submit">
<input type="submit" value="Search Jobs"> <%= submit_tag "Search Jobs", name: nil %>
</div> </div>
</div> </div>
<ul class="job_types"> <% end %>
<li><label for="job_type_freelance" class="freelance"><input type="checkbox" name="filter_job_type[]" value="freelance" id="job_type_freelance" /> Freelance</label></li>
<li><label for="job_type_full-time" class="full-time"><input type="checkbox" name="filter_job_type[]" value="full-time" id="job_type_full-time" /> Full Time</label></li>
<li><label for="job_type_internship" class="internship"><input type="checkbox" name="filter_job_type[]" value="internship" id="job_type_internship" /> Internship</label></li>
<li><label for="job_type_part-time" class="part-time"><input type="checkbox" name="filter_job_type[]" value="part-time" id="job_type_part-time" /> Part Time</label></li>
<li><label for="job_type_temporary" class="temporary"><input type="checkbox" name="filter_job_type[]" value="temporary" id="job_type_temporary" /> Temporary</label></li>
</ul>
<input type="hidden" name="filter_job_type[]" value="" />
<div class="showing_jobs"></div>
</form>
</div> </div>
</div> </div>
</section> </section>
......
...@@ -14,15 +14,6 @@ ...@@ -14,15 +14,6 @@
<label for="search_keywords">Keywords</label> <label for="search_keywords">Keywords</label>
<input type="text" name="search_keywords" id="search_keywords" placeholder="Keywords" value="" /> <input type="text" name="search_keywords" id="search_keywords" placeholder="Keywords" value="" />
</div> </div>
<div class="search_categories">
<label for="search_categories">Category</label>
<select name='search_categories[]' id='search_categories' class='job-manager-category-dropdown ' data-placeholder='Choose a category&hellip;' data-no_results_text='No results match' data-multiple_text='Select Some Options'>
<option value="">Any category</option>
<option class="level-0" value="17">Design</option>
<option class="level-0" value="18">Developement</option>
<option class="level-0" value="49">Marketing</option>
</select>
</div>
<div class="search_submit"> <div class="search_submit">
<input type="submit" name="submit" value="Search"> <input type="submit" name="submit" value="Search">
</div> </div>
...@@ -32,6 +23,7 @@ ...@@ -32,6 +23,7 @@
</div> </div>
</form> </form>
<noscript>Your browser does not support JavaScript, or it is disabled. JavaScript must be enabled in order to view listings.</noscript> <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"> <ul class="job_listings">
<% @jobs.each do |job| %> <% @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"> <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">
...@@ -69,6 +61,7 @@ ...@@ -69,6 +61,7 @@
<div class="job-manager-pagination"> <div class="job-manager-pagination">
<%= paginate @jobs %> <%= paginate @jobs %>
</div> </div>
<% end %>
</div> </div>
</div> </div>
</div> </div>
......
<% content_for :title, "VenJob - Search Jobs" %>
<div id="primary" role="main">
<!-- <div class="job_listing-map-wrapper">
<div class="job_listing-map">
<div id="job_listing-map-canvas"></div>
</div>
</div> -->
<div class="container content-area">
<div class="entry-content">
<div class="job_listings">
<%= form_tag(search_jobs_path, :method => "get", :class => "job_filters") 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]%>" />
</div>
<div class="search_submit">
<%= submit_tag "Search Jobs", name: nil %>
</div>
</div>
<div class="showing_jobs">
<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| %>
<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_path(id: job["job_id"]) do %>
<img class="company_logo" src="<%= job["company_logo"] != "" ? job["company_logo"] : "https://via.placeholder.com/66x38?text=Logo" %>" alt="<%= job["company_name"] %>">
<% end %>
</div>
<div class="job_listing-about">
<div class="job_listing-position job_listing__column">
<h3 class="job_listing-title">
<%= link_to job["job_title"], job_path(id: job["job_id"]) %>
</h3>
<div class="job_listing-company">
<strong>
<%= link_to job["company_name"], jobs_with_company_path(company_id: job["company_id"]) %>
</strong>
</div>
</div>
<div class="job_listing-location job_listing__column">
<% job["city_ids"].each_with_index do |city_id, index| %>
<%= link_to jobs_with_city_path(city_id: city_id), class: "google_map_link" do %>
<%= job["city_names"][index] %><%= ", " if index != job["city_ids"].size - 1 %>
<% end %>
<% end %>
</div>
<ul class="job_listing-meta job_listing__column">
<li class="job_listing-type job-type part-time"><%= job["salary"] == 0 ? "Thuương lượng" : job["salary"] %></li>
<li class="job_listing-date"><%= job["expiration_date"] > 0 ? Time.at(job["expiration_date"]).to_date.to_s : "" %></li>
</ul>
</div>
</li>
<% end %>
</ul>
<div class="job-manager-pagination">
<%= will_paginate @jobs %>
</div>
<% end %>
</div>
</div>
</div>
</div>
\ No newline at end of file
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
</form> </form>
<div class="nav-menu nav-menu--primary"> <div class="nav-menu nav-menu--primary">
<ul id="menu-main-menu" class="nav-menu nav-menu--primary"> <ul id="menu-main-menu" class="nav-menu nav-menu--primary">
<% if !current_admin %>
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-99991208"> <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-99991208">
<a href="/jobs">Find A Job</a> <a href="/jobs">Find A Job</a>
</li> </li>
...@@ -66,6 +67,16 @@ ...@@ -66,6 +67,16 @@
<%= link_to 'Sign in', new_user_session_path %> <%= link_to 'Sign in', new_user_session_path %>
</li> </li>
<% end %> <% end %>
<% else %>
<% if current_admin %>
<li class="register menu-item menu-item-type-post_type menu-item-object-page menu-item-99991219">
<%= link_to 'Applies', admins_applies_path %>
</li>
<li class="login menu-item menu-item-type-post_type menu-item-object-page menu-item-99991213">
<%= link_to 'Admin sign out', destroy_admin_session_path, method: :delete %>
</li>
<% end %>
<% end %>
</ul> </ul>
</div> </div>
</nav> </nav>
......
<h2>Resend confirmation instructions</h2>
<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, autocomplete: "email", value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
</div>
<div class="actions">
<%= f.submit "Resend confirmation instructions" %>
</div>
<% end %>
<%= render "users/shared/links" %>
<p>Welcome <%= @email %>!</p>
<p>You can confirm your account email through the link below:</p>
<p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p>
<p>Hello <%= @email %>!</p>
<% if @resource.try(:unconfirmed_email?) %>
<p>We're contacting you to notify you that your email is being changed to <%= @resource.unconfirmed_email %>.</p>
<% else %>
<p>We're contacting you to notify you that your email has been changed to <%= @resource.email %>.</p>
<% end %>
<p>Hello <%= @resource.email %>!</p>
<p>We're contacting you to notify you that your password has been changed.</p>
<p>Hello <%= @resource.email %>!</p>
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
<p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>
<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
<p>Hello <%= @resource.email %>!</p>
<p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p>
<p>Click the link below to unlock your account:</p>
<p><%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %></p>
<h2>Change your password</h2>
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<%= f.hidden_field :reset_password_token %>
<div class="field">
<%= f.label :password, "New password" %><br />
<% if @minimum_password_length %>
<em>(<%= @minimum_password_length %> characters minimum)</em><br />
<% end %>
<%= f.password_field :password, autofocus: true, autocomplete: "new-password" %>
</div>
<div class="field">
<%= f.label :password_confirmation, "Confirm new password" %><br />
<%= f.password_field :password_confirmation, autocomplete: "new-password" %>
</div>
<div class="actions">
<%= f.submit "Change my password" %>
</div>
<% end %>
<%= render "users/shared/links" %>
<% content_for :title, "VenJob - Forgot your password" %>
<header class="page-header">
<h2 class="page-title">Forgot your password</h2>
</header>
<div id="primary" class="content-area container" role="main">
<article id="post-1673" class="post-1673 page type-page status-publish hentry">
<div class="entry-content">
<div class="registration-form woocommerce">
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<p class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, autocomplete: "email", placeholder: "Email" %>
</p>
<p class="actions">
<%= f.submit "Send me reset password instructions", class: "button" %>
</p>
<% end %>
<p>
<%= render "devise/shared/links" %>
</p>
</div>
</div>
</article>
</div>
\ No newline at end of file
<% content_for :title, "VenJob - Edit #{resource_name.to_s.humanize}" %>
<header class="page-header">
<h2 class="page-title">Edit <%= resource_name.to_s.humanize %></h2>
</header>
<div id="primary" class="content-area container" role="main">
<article id="post-1673" class="post-1673 page type-page status-publish hentry">
<div class="entry-content">
<div class="registration-form woocommerce">
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<p class="field">
<%= f.label :full_name %><br />
<%= f.text_field :full_name, placeholder: "Fullname" %>
</p>
<p class="field">
<%= f.label :email %><br />
<%= f.email_field :email, placeholder: "Email" %>
</p>
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
<p>Currently waiting confirmation for: <%= resource.unconfirmed_email %></p>
<% end %>
<p class="field">
<%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
<%= f.password_field :password, autocomplete: "new-password", placeholder: "Password" %>
<% if @minimum_password_length %>
<br />
<em><%= @minimum_password_length %> characters minimum</em>
<% end %>
</p>
<p class="field">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "new-password", placeholder: "Confirm password" %>
</p>
<p class="field">
<%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
<%= f.password_field :current_password, autocomplete: "current-password", placeholder: "Current password" %>
</p>
<fieldset class="fieldset-featured_image fieldset-type-file">
<%= f.label :cv %>
<div class="field ">
<label for="user_cv" class="file-field-label">
<div class="job-manager-uploaded-files">
</div>
<%= f.file_field :cv, accept: "application/pdf,.xls,.xlsx,.doc,.zip" %>
<span class="button button--size-medium">
Choose file
</span>
</label>
<small class="description file-field-description">
Allowed format: doc, pdf, xls, xlsx, zip. Maxium size: 5MB.
</small>
</div>
</fieldset>
<p class="actions" style="text-align: center;">
<%= f.submit "Update", class: "button" %>
</p>
<% end %>
</div>
</div>
</article>
</div>
\ No newline at end of file
<% content_for :title, "VenJob - Sign Up" %>
<header class="page-header">
<h2 class="page-title">Sign Up</h2>
</header>
<div id="primary" class="content-area container" role="main">
<article id="post-1673" class="post-1673 page type-page status-publish hentry">
<div class="entry-content">
<div class="registration-form woocommerce">
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<p class="field">
<%= f.label :full_name %><br />
<%= f.text_field :full_name, autofocus: true, autocomplete: "full_name" %>
</p>
<p class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autocomplete: "email" %>
</p>
<p class="field">
<%= f.label :password %>
<% if @minimum_password_length %>
<em>(<%= @minimum_password_length %> characters minimum)</em>
<% end %><br />
<%= f.password_field :password, autocomplete: "new-password" %>
</p>
<p class="field">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "new-password" %>
</p>
<p class="actions">
<%= f.submit "Sign up", class: "button" %>
</p>
<% end %>
<p>
Do you have account? <%= render "devise/shared/links" %>
</p>
</div>
</div>
</article>
</div>
\ No newline at end of file
<% content_for :title, "VenJob - Sign In" %>
<header class="page-header">
<h2 class="page-title">Sign In</h2>
</header>
<div id="primary" class="content-area container" role="main">
<article id="post-1673" class="post-1673 page type-page status-publish hentry">
<div class="entry-content">
<div class="registration-form woocommerce">
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
<p class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
</p>
<p class="field">
<%= f.label :password %><br />
<%= f.password_field :password, autocomplete: "current-password" %>
</p>
<% if devise_mapping.rememberable? %>
<p class="field">
<%= f.check_box :remember_me %>
<%= f.label :remember_me %>
</p>
<% end %>
<p class="actions">
<%= f.submit "Log in", class: "button" %>
</p>
<% end %>
<p>
<%= render "devise/shared/links" %>
</p>
</div>
</div>
</article>
</div>
\ No newline at end of file
<% if resource.errors.any? %>
<div id="error_explanation">
<h2>
<%= I18n.t("errors.messages.not_saved",
count: resource.errors.count,
resource: resource.class.model_name.human.downcase)
%>
</h2>
<ul>
<% resource.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<%- if controller_name != 'sessions' %>
<%= link_to "Log in", new_session_path(resource_name) %><br />
<% end %>
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
<% end %>
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
<% end %>
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
<% end %>
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
<% end %>
<%- if devise_mapping.omniauthable? %>
<%- resource_class.omniauth_providers.each do |provider| %>
<%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider) %><br />
<% end %>
<% end %>
<h2>Resend unlock instructions</h2>
<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
<%= render "devise/shared/error_messages", resource: resource %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
</div>
<div class="actions">
<%= f.submit "Resend unlock instructions" %>
</div>
<% end %>
<%= render "users/shared/links" %>
...@@ -232,7 +232,7 @@ Devise.setup do |config| ...@@ -232,7 +232,7 @@ Devise.setup do |config|
# Turn scoped views on. Before rendering "sessions/new", it will first check for # Turn scoped views on. Before rendering "sessions/new", it will first check for
# "users/sessions/new". It's turned off by default because it's slower if you # "users/sessions/new". It's turned off by default because it's slower if you
# are using only default views. # are using only default views.
# config.scoped_views = false config.scoped_views = true
# Configure the default scope given to Warden. By default it's the first # Configure the default scope given to Warden. By default it's the first
# devise role declared in your routes (usually :user). # devise role declared in your routes (usually :user).
......
Rails.application.routes.draw do Rails.application.routes.draw do
devise_for :admins devise_for :admins, controllers: {
devise_for :users sessions: 'admins/sessions'
}
devise_for :users, controllers: {
sessions: 'users/sessions'
}
# 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
root to: 'home#index' root to: 'home#index'
...@@ -9,14 +13,16 @@ Rails.application.routes.draw do ...@@ -9,14 +13,16 @@ Rails.application.routes.draw do
get '/jobs/city/:city_id', to: 'jobs#index', as: 'jobs_with_city' get '/jobs/city/:city_id', to: 'jobs#index', as: 'jobs_with_city'
get '/jobs/industry/:industry_id', to: 'jobs#index', as: 'jobs_with_industry' get '/jobs/industry/:industry_id', to: 'jobs#index', as: 'jobs_with_industry'
get '/jobs/company/:company_id', to: 'jobs#index', as: 'jobs_with_company' get '/jobs/company/:company_id', to: 'jobs#index', as: 'jobs_with_company'
get '/search', to: 'jobs#search', as: 'search_jobs'
get '/cities/', to: 'cities#index', as: 'cities' get '/cities/', to: 'cities#index', as: 'cities'
get '/industries/', to: 'industries#index', as: 'industries' get '/industries/', to: 'industries#index', as: 'industries'
get '/history/', to: 'history#index' get '/history/', to: 'history#index'
get '/users/info', to: 'users#info' get '/users/info', to: 'users#info'
get '/users/applied-jobs', to: 'users#apply_jobs' get '/users/applied-jobs', to: 'users#apply_jobs'
get '/users/favorite-jobs', to: 'users#favorite_jobs' get '/users/favorite-jobs', to: 'users#favorite_jobs'
get '/admins/applies', to: 'admins#applies', as: 'admins_applies'
post '/apply_or_favorite', to: 'users#apply_or_favorite_jobs' post '/apply_or_favorite', to: 'users#apply_or_favorite_jobs'
delete 'remove_favorite_job', to: 'users#remove_favorite_job' delete '/remove_favorite_job', to: 'users#remove_favorite_job'
end end
...@@ -2,28 +2,14 @@ require "rsolr" ...@@ -2,28 +2,14 @@ require "rsolr"
namespace :solr do namespace :solr do
desc "Solr management" desc "Solr management"
solr = RSolr.connect :url => "http://localhost:8983/solr/venjob" solr_job = RSolr.connect :url => "http://localhost:8983/solr/job"
solr_apply = RSolr.connect :url => "http://localhost:8983/solr/apply"
task import: :environment do task import_job: :environment do
job = Job.all jobs = Job.all
hash_jobs = job.map { |item| hash_jobs = jobs.map { |item|
salary = 0
min_salary = 0
max_salary = 0
{ {
job_id: item.id, apply_count: Apply.where("job_id = ?", item.id).count,
title: item.title,
updated_date_job: item.updated_date_job.nil? ? 0 : DateTime.parse(item.updated_date_job).to_i,
level: item.level,
years_of_experience: item.years_of_experience,
salary: salary,
min_salary: min_salary,
max_salary: max_salary,
expiration_date: item.expiration_date.nil? ? 0 : DateTime.parse(item.expiration_date).to_i,
job_description: item.job_description,
created_at: item.created_at.to_i,
industry_ids: item.industries.map { |industry| industry.id },
industry_names: item.industries.map { |industry| industry.title },
city_ids: item.cities.map { |city| city.id }, city_ids: item.cities.map { |city| city.id },
city_names: item.cities.map { |city| city.title }, city_names: item.cities.map { |city| city.title },
company_id: item.company_id, company_id: item.company_id,
...@@ -31,15 +17,49 @@ namespace :solr do ...@@ -31,15 +17,49 @@ namespace :solr do
company_address: item.company.address, company_address: item.company.address,
company_description: item.company.description, company_description: item.company.description,
company_logo: item.company.logo, 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, favorite_count: Favorite.where("job_id = ?", item.id).count,
apply_count: Apply.where("job_id = ?", item.id).count industry_ids: item.industries.map { |industry| industry.id },
industry_names: item.industries.map { |industry| industry.title },
job_description: item.job_description,
job_id: item.id,
job_title: item.title,
level: item.level,
salary: item.salary,
updated_date_job: item.updated_date_job.nil? ? 0 : DateTime.parse(item.updated_date_job).to_i,
years_of_experience: item.years_of_experience
} }
} }
solr.add hash_jobs solr_job.add hash_jobs
solr.commit 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 end
task delete_all: :environment do task delete_all_apply: :environment do
solr.delete_by_query "*:*" solr_apply.delete_by_query "*:*"
solr.commit solr_apply.commit
end end
end end
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
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