Commit 475139e9 by Hoang Phuc

Clean code

parent cb35c893
Pipeline #631 failed with stages
in 0 seconds
class HistoryController < ApplicationController
def index
if cookies[:job_ids_history].nil?
redirect_to "/jobs"
else
return redirect_to jobs_path if cookies[:job_ids_history].blank?
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")
end
end
end
\ No newline at end of file
class UsersController < ApplicationController
def info
unless user_signed_in?
redirect_to "/users/sign_in"
end
redirect_to user_session_path unless user_signed_in?
end
def apply_jobs
unless user_signed_in?
redirect_to "/users/sign_in"
else
@applied_jobs = Apply.where("user_id = ?", current_user.id)
end
redirect_to user_session_path unless user_signed_in?
@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
redirect_to user_session_path unless user_signed_in?
@favorite_jobs = Favorite.where("user_id = #{current_user.id}")
end
def apply_or_favorite_jobs
unless user_signed_in?
payload = {
......@@ -40,6 +37,7 @@ class UsersController < ApplicationController
end
end
end
def remove_favorite_job
unless user_signed_in?
payload = {
......
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
......
......@@ -12,7 +12,7 @@
ActiveRecord::Schema.define(version: 2020_05_18_023337) do
create_table "admins", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
create_table "admins", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
......@@ -24,7 +24,7 @@ ActiveRecord::Schema.define(version: 2020_05_18_023337) do
t.index ["reset_password_token"], name: "index_admins_on_reset_password_token", unique: true
end
create_table "applies", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
create_table "applies", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci", force: :cascade do |t|
t.bigint "user_id", null: false
t.bigint "job_id", null: false
t.datetime "created_at", precision: 6, null: false
......@@ -33,21 +33,21 @@ ActiveRecord::Schema.define(version: 2020_05_18_023337) do
t.index ["user_id"], name: "index_applies_on_user_id"
end
create_table "cities", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
create_table "cities", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci", force: :cascade do |t|
t.string "title"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.boolean "foreign", default: false
end
create_table "cities_jobs", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
create_table "cities_jobs", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci", force: :cascade do |t|
t.bigint "city_id", null: false
t.bigint "job_id", null: false
t.index ["city_id", "job_id"], name: "index_cities_jobs_on_city_id_and_job_id"
t.index ["job_id", "city_id"], name: "index_cities_jobs_on_job_id_and_city_id"
end
create_table "companies", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
create_table "companies", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci", force: :cascade do |t|
t.string "title"
t.string "address"
t.string "logo"
......@@ -56,7 +56,7 @@ ActiveRecord::Schema.define(version: 2020_05_18_023337) do
t.datetime "updated_at", precision: 6, null: false
end
create_table "favorites", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
create_table "favorites", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci", force: :cascade do |t|
t.bigint "user_id", null: false
t.bigint "job_id", null: false
t.datetime "created_at", precision: 6, null: false
......@@ -65,20 +65,20 @@ ActiveRecord::Schema.define(version: 2020_05_18_023337) do
t.index ["user_id"], name: "index_favorites_on_user_id"
end
create_table "industries", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
create_table "industries", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci", force: :cascade do |t|
t.string "title"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
create_table "industries_jobs", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
create_table "industries_jobs", id: false, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci", force: :cascade do |t|
t.bigint "industry_id", null: false
t.bigint "job_id", null: false
t.index ["industry_id", "job_id"], name: "index_industries_jobs_on_industry_id_and_job_id"
t.index ["job_id", "industry_id"], name: "index_industries_jobs_on_job_id_and_industry_id"
end
create_table "jobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
create_table "jobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci", force: :cascade do |t|
t.string "title"
t.string "updated_date_job"
t.string "level"
......@@ -97,7 +97,7 @@ ActiveRecord::Schema.define(version: 2020_05_18_023337) do
t.index ["company_id"], name: "index_jobs_on_company_id"
end
create_table "users", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", force: :cascade do |t|
create_table "users", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
......@@ -110,6 +110,7 @@ ActiveRecord::Schema.define(version: 2020_05_18_023337) do
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.string "full_name"
t.string "image"
t.string "cv"
t.string "provider"
t.string "uid"
......
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