Commit ff55254b by Hoang Phuc

Rsolr, meta tags, export csv

parent 8972345e
Pipeline #601 failed with stages
in 0 seconds
......@@ -43,6 +43,8 @@ gem 'bootsnap', '>= 1.4.2', require: false
# Pagination
gem 'kaminari'
gem 'meta-tags'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
......
......@@ -133,6 +133,8 @@ GEM
mini_mime (>= 0.1.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
meta-tags (2.13.0)
actionpack (>= 3.2.0, < 6.1)
method_source (1.0.0)
mimemagic (0.3.4)
mini_magick (4.10.1)
......@@ -301,6 +303,7 @@ DEPENDENCIES
jbuilder (~> 2.7)
kaminari
listen (>= 3.0.5, < 3.2)
meta-tags
mysql2
pry
puma (~> 4.1)
......
......@@ -372,6 +372,9 @@ nav.pagination span.current{
.wp-job-manager-categories-enabled .search_jobs div.search_keywords{
width: 73%;
}
.export-csv{
float: right;
}
@media screen and (min-width: 1200px) {
.job_listing-about, .resume-about {
width: 90%;
......
......@@ -17,9 +17,14 @@ class AdminsController < ApplicationController
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"]
@applies = RsolrService.new.query_apply(query_params,params[:page])
end
def export_csv
# csv = ExportCsvService.new(Job.all.limit(10), Job::EXPORT_CSV_ATTRIBUTES)
# respond_to do |format|
# format.csv { send_data csv.perform,
# filename: "jobs.csv" }
# end
end
end
require "rsolr"
class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?
before_action :solr_job
before_action :solr_apply
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:full_name])
devise_parameter_sanitizer.permit(:account_update, keys: [:full_name, :cv])
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
......@@ -40,14 +40,9 @@ class JobsController < ApplicationController
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
return redirect_to root_path, alert: "Empty field!" if params[:keyword].blank?
response = RsolrService.new.query_job("job_title:#{params[:keyword]}", params[:page])
@jobs = response["response"]["docs"]
@amount_job = response["response"]["numFound"]
end
end
......@@ -13,4 +13,6 @@ 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}")}
EXPORT_CSV_ATTRIBUTES = %w(title updated_date_job level years_of_experience salary expiration_date).freeze
end
require "csv"
class ExportCsvService
def initialize objects, attributes
@objects = objects
@attributes = attributes
@header = @attributes.map{ |attr| I18n.t("header_csv.#{attr}")}
end
def perform
CSV.generate do |csv|
csv << header
objects.each do |object|
csv << attributes.map{ |attr| object.public_send(attr) }
end
end
end
private
attr_reader :objects, :attributes, :header
end
\ No newline at end of file
require "rsolr"
class RsolrService
attr_accessor :solr_job, :solr_apply, :apply, :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
}
end
end
\ No newline at end of file
......@@ -59,7 +59,7 @@
</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;">
<%# link_to "CSV Download", admins_applies_path(format: :csv), class: "button export-csv" %>
</p>
<% end %>
<div class="clearfix"></div>
......
<% content_for :title, "VenJob - Cities" %>
<% set_meta_tags title: "VenJob - Cities",
description: "VenJob - Cities",
keywords: "VenJob - Cities" %>
<header class="page-header">
<h2 class="page-title">Cities</h2>
</header>
......
<%= content_for :title, "VenJob - History" %>
<% set_meta_tags title: "VenJob - History",
description: "VenJob - History",
keywords: "VenJob - History" %>
<header class="page-header">
<h2 class="page-title">History</h2>
</header>
......
<% content_for :title, "VenJob - Homepage" %>
<% set_meta_tags title: "VenJob - Homepage",
description: "VenJob - Homepage",
keywords: "VenJob - Homepage" %>
<div id="primary" role="main">
<section id="jobify_widget_search_hero-2" class="widget widget--home widget--home--no-margin widget--home-hero-search">
<div class="hero-search hero-search--no-overlay hero-search--height-medium">
......
<% content_for :title, "VenJob - Industries" %>
<% set_meta_tags title: "VenJob - Industries",
description: "VenJob - Industries",
keywords: "VenJob - Industries" %>
<header class="page-header">
<h2 class="page-title">Industries</h2>
</header>
......
<% content_for :title, "VenJob - Jobs" %>
<% set_meta_tags title: "VenJob - Jobs",
description: "VenJob - Jobs",
keywords: "VenJob - Jobs" %>
<div id="primary" role="main">
<!-- <div class="job_listing-map-wrapper">
<div class="job_listing-map">
......
<% content_for :title, "VenJob - Search Jobs" %>
<% set_meta_tags title: "VenJob - Search",
description: "VenJob - Search",
keywords: "VenJob - Search" %>
<div id="primary" role="main">
<!-- <div class="job_listing-map-wrapper">
<div class="job_listing-map">
......
<% content_for :title, @title %>
<% set_meta_tags title: @job.title,
description: @job.title,
keywords: @job.title %>
<div class="single_job_listing">
<% if @job.present? %>
<div class="page-header">
......
<!DOCTYPE html>
<html>
<head>
<title><%= yield(:title)%></title>
<%= display_meta_tags %>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
......@@ -14,7 +14,7 @@
<%= javascript_include_tag "/assets/js/jquery-migrate.min.js" %>
<%= javascript_include_tag "https://maps.googleapis.com/maps/api/js?v=3&#038;libraries=geometry%2Cplaces&#038;language=en&#038;key=AIzaSyDFtSmGkBIXtMX63-bZKn50-6p3vZ2-WHE&#038;ver=5.3.2" %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
<body class="home page-template page-template-page-templates page-template-jobify page-template-page-templatesjobify-php page page-id-25 woocommerce-no-js single-listing-style-side single-resume-style-side wp-job-manager-categories-enabled wp-job-manager wp-job-manager-bookmarks ninjaforms-contact-job-form wp-job-manager-contact-listing woocommerce testimonials ninja-forms jetpack custom-font nav-menu-break-large fixed-header jobify-child">
......
# frozen_string_literal: true
# Use this setup block to configure all options available in MetaTags.
MetaTags.configure do |config|
# How many characters should the title meta tag have at most. Default is 70.
# Set to nil or 0 to remove limits.
# config.title_limit = 70
# When true, site title will be truncated instead of title. Default is false.
# config.truncate_site_title_first = false
# Maximum length of the page description. Default is 300.
# Set to nil or 0 to remove limits.
# config.description_limit = 300
# Maximum length of the keywords meta tag. Default is 255.
# config.keywords_limit = 255
# Default separator for keywords meta tag (used when an Array passed with
# the list of keywords). Default is ", ".
# config.keywords_separator = ', '
# When true, keywords will be converted to lowercase, otherwise they will
# appear on the page as is. Default is true.
# config.keywords_lowercase = true
# When true, the output will not include new line characters between meta tags.
# Default is false.
# config.minify_output = false
# When false, generated meta tags will be self-closing (<meta ... />) instead
# of open (`<meta ...>`). Default is true.
# config.open_meta_tags = true
# List of additional meta tags that should use "property" attribute instead
# of "name" attribute in <meta> tags.
# config.property_tags.push(
# 'x-hearthstone:deck',
# )
end
......@@ -31,3 +31,10 @@
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
defaults: &defaults
home:
limit: 10
admin:
limit: 5
search:
limit: 25
development:
<<: *defaults
\ No newline at end of file
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