Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
  • This project
    • Loading...
  • Sign in / Register
V
venjob_nth
  • Overview
    • Overview
    • Details
    • Activity
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 0
    • Issues 0
    • List
    • Board
    • Labels
    • Milestones
  • Merge Requests 3
    • Merge Requests 3
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Wiki
    • Wiki
  • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Ngô Trung Hưng
  • venjob_nth
  • Merge Requests
  • !15

Merged
Opened Aug 31, 2020 by Ngô Trung Hưng@hungnt 
  • Report abuse
Report abuse

create func search & auto index data to solr server

×

Check out, review, and merge locally

Step 1. Fetch and check out the branch for this merge request

git fetch origin
git checkout -b feature/search origin/feature/search

Step 2. Review the changes locally

Step 3. Merge the branch and fix any conflicts that come up

git checkout master
git merge --no-ff feature/search

Step 4. Push the result of the merge to GitLab

git push origin master

Note that pushing to GitLab requires write access to this repository.

Tip: You can also checkout merge requests locally by following these guidelines.

  • Discussion 57
  • Commits 12
  • Pipelines 12
  • Changes 52
{{ resolvedDiscussionCount }}/{{ discussionCount }} {{ resolvedCountText }} resolved
  • Ngô Trung Hưng @hungnt

    added 1 commit

    • 5bdd43ef - use solr_escape

    Compare with previous version

    Aug 31, 2020

    added 1 commit

    • 5bdd43ef - use solr_escape

    Compare with previous version

    added 1 commit * 5bdd43ef - use solr_escape [Compare with previous version](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5163&start_sha=99779d23baea4e08086af5e7c915c1a888eb17bc)
    Toggle commit list
  • Hiếu Lê
    @hieulh started a discussion on an old version of the diff Aug 31, 2020
    Resolved by Hoang Phuc Do Aug 31, 2020
    .vscode/settings.json 0 → 100644
    1 {
    2 "compile-hero.disable-compile-files-on-did-save-code": true
    3 }
    • Hiếu Lê @hieulh commented Aug 31, 2020

      Không push config của cá nhân lên, cụ thể bỏ thư mục .vscode vào git ignore luôn.

      Edited Aug 31, 2020
      Không push config của cá nhân lên, cụ thể bỏ thư mục `.vscode` vào git ignore luôn.
    • Ngô Trung Hưng @hungnt commented Aug 31, 2020
      Master

      Dạ anh

      Edited Aug 31, 2020
      Dạ anh
    • Ngô Trung Hưng @hungnt

      changed this line in version 12 of the diff

      Sep 10, 2020

      changed this line in version 12 of the diff

      changed this line in [version 12 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5200&start_sha=25cfc16c407f532ef1dcca18c63bd1b849a154f9#89aa447020cdcb580cea0495694d46a55941edbe_3_0)
      Toggle commit list
    Please register or sign in to reply
  • Hiếu Lê
    @hieulh started a discussion on an old version of the diff Aug 31, 2020
    Resolved by Hoang Phuc Do Aug 31, 2020
    app/controllers/histories_controller.rb
    5 5
    6 6 def index
    7 7 histories = current_user.histories.order(created_at: :desc)
    8 @jobs = histories.map(&:job)
    8 @jobs = histories.map(&:job).select { |val| val.present? }
    • Hiếu Lê @hieulh commented Aug 31, 2020

      .select { |val| val.present? } viết lại sao cho ngắn và đơn giản hơn.

      Edited Aug 31, 2020
      `.select { |val| val.present? }` viết lại sao cho ngắn và đơn giản hơn.
    • Ngô Trung Hưng @hungnt commented Aug 31, 2020
      Master

      dạ anh

      Edited Aug 31, 2020
      dạ anh
    • Ngô Trung Hưng @hungnt

      changed this line in version 3 of the diff

      Aug 31, 2020

      changed this line in version 3 of the diff

      changed this line in [version 3 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5164&start_sha=5bdd43ef593c94dd247e0cc3d9e1c71551661100#7b5d95868f77b79b5fd7082706857062a350373f_8_8)
      Toggle commit list
    Please register or sign in to reply
  • Hiếu Lê
    @hieulh started a discussion on an old version of the diff Aug 31, 2020
    Resolved by Hoang Phuc Do Aug 31, 2020
    app/controllers/search_controller.rb 0 → 100644
    1 class SearchController < ApplicationController
    2 NUMBER_RECORD_IN_PAGE = 10
    3 before_action :load_data_dropdown, only: :multi_search
    4
    5 def multi_search
    6 solr = connect_solr
    7 @keyword = params[:keyword]
    8 @industry = Industry.find_by(id: params[:industry]) if params[:industry].present?
    • Hiếu Lê @hieulh commented Aug 31, 2020

      id: params[:industry] Tên params nên rõ ràng hơn như id: params[:industry_id], sau này đọc vào biết mình truyền vào nó là id chứ ko phải 1 đối tượng.

      Tương tự như city,...

      Edited Aug 31, 2020 by Hiếu Lê
      `id: params[:industry]` Tên params nên rõ ràng hơn như `id: params[:industry_id]`, sau này đọc vào biết mình truyền vào nó là id chứ ko phải 1 đối tượng. Tương tự như `city`,...
    • Ngô Trung Hưng @hungnt commented Aug 31, 2020
      Master

      dạ anh, e fix ngay

      Edited Aug 31, 2020
      dạ anh, e fix ngay
    • Ngô Trung Hưng @hungnt

      changed this line in version 3 of the diff

      Aug 31, 2020

      changed this line in version 3 of the diff

      changed this line in [version 3 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5164&start_sha=5bdd43ef593c94dd247e0cc3d9e1c71551661100#504ab799da80c4c1fdb6316833bcac0b90d13572_8_8)
      Toggle commit list
    Please register or sign in to reply
  • Hiếu Lê
    @hieulh started a discussion on an old version of the diff Aug 31, 2020
    Resolved by Hoang Phuc Do Aug 31, 2020
    app/controllers/search_controller.rb 0 → 100644
    1 class SearchController < ApplicationController
    2 NUMBER_RECORD_IN_PAGE = 10
    3 before_action :load_data_dropdown, only: :multi_search
    4
    5 def multi_search
    6 solr = connect_solr
    7 @keyword = params[:keyword]
    8 @industry = Industry.find_by(id: params[:industry]) if params[:industry].present?
    9 @city = City.find_by(id: params[:city]) if params[:city].present?
    10 # Value data is Array, index[0]: name_job or company name, index[1]: id industry, index[2]: id location
    11 data = sub_space_params!(params[:keyword], params[:industry], params[:city])
    • Hiếu Lê @hieulh commented Aug 31, 2020

      Hàm sub_space_params xử lý hơi phức tạp và biến trả về không rõ ràng, sau này muốn biết data[0] là gì lại phải đọc logic hàm xử lý, trong khi đó có thể trả về kiểu có tên biến rõ ràng hơn như hash chẳng hạn

      Edited Aug 31, 2020
      Hàm `sub_space_params` xử lý hơi phức tạp và biến trả về không rõ ràng, sau này muốn biết `data[0]` là gì lại phải đọc logic hàm xử lý, trong khi đó có thể trả về kiểu có tên biến rõ ràng hơn như hash chẳng hạn
    • Ngô Trung Hưng @hungnt commented Aug 31, 2020
      Master

      dạ, e sẽ chuyển qua dùng hash

      Edited Aug 31, 2020
      dạ, e sẽ chuyển qua dùng hash
    • Ngô Trung Hưng @hungnt

      changed this line in version 3 of the diff

      Aug 31, 2020

      changed this line in version 3 of the diff

      changed this line in [version 3 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5164&start_sha=5bdd43ef593c94dd247e0cc3d9e1c71551661100#504ab799da80c4c1fdb6316833bcac0b90d13572_11_8)
      Toggle commit list
    Please register or sign in to reply
  • Hiếu Lê
    @hieulh started a discussion on an old version of the diff Aug 31, 2020
    Resolved by Hoang Phuc Do Sep 07, 2020
    app/controllers/search_controller.rb 0 → 100644
    11 data = sub_space_params!(params[:keyword], params[:industry], params[:city])
    12 query = if params[:keyword].blank? && params[:industry].blank? && params[:city].blank?
    13 '*:*'
    14 else
    15 "solr((name: #{data[0]}) OR (company_name: #{data[0]})) AND (industry_id: #{data[1]}) AND (location_id: #{data[2]})"
    16 end
    17 response = solr.paginate(params[:page], NUMBER_RECORD_IN_PAGE, 'select', params: { q: query })
    18 @results = Kaminari.paginate_array(response['response']['docs'], total_count: response['response']['numFound']).page(params[:page]).per(NUMBER_RECORD_IN_PAGE)
    19 return render 'error/page_not_found' if params[:page].to_i > @results.total_pages
    20
    21 render :result
    22 end
    23
    24 def sub_space_params!(keyword, industry_id, location_id)
    25 arr_params = []
    26 keyword = keyword.present? ? RSolr.solr_escape(keyword) : ''
    • Hiếu Lê @hieulh commented Aug 31, 2020

      keyword.present? ? RSolr.solr_escape(keyword) : '' Em thử cách khác viết ngắn hơn xem được ko

      Edited Aug 31, 2020
      `keyword.present? ? RSolr.solr_escape(keyword) : ''` Em thử cách khác viết ngắn hơn xem được ko
    • Ngô Trung Hưng @hungnt commented Aug 31, 2020
      Master

      dạ e nghiên cứu rồi viết lại

      dạ e nghiên cứu rồi viết lại
    • Ngô Trung Hưng @hungnt

      changed this line in version 3 of the diff

      Aug 31, 2020

      changed this line in version 3 of the diff

      changed this line in [version 3 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5164&start_sha=5bdd43ef593c94dd247e0cc3d9e1c71551661100#504ab799da80c4c1fdb6316833bcac0b90d13572_26_24)
      Toggle commit list
    Please register or sign in to reply
  • Hiếu Lê
    @hieulh started a discussion on an old version of the diff Aug 31, 2020
    Resolved by Ngô Trung Hưng Aug 31, 2020
    app/controllers/search_controller.rb 0 → 100644
    19 return render 'error/page_not_found' if params[:page].to_i > @results.total_pages
    20
    21 render :result
    22 end
    23
    24 def sub_space_params!(keyword, industry_id, location_id)
    25 arr_params = []
    26 keyword = keyword.present? ? RSolr.solr_escape(keyword) : ''
    27 industry_id = industry_id.present? ? RSolr.solr_escape(industry_id) : ''
    28 location_id = location_id.present? ? RSolr.solr_escape(location_id) : ''
    29 arr_params << keyword << industry_id << location_id
    30 arr_params.each { |val| val.sub!('', '*') if val.blank? }
    31 end
    32
    33 def load_data_dropdown
    34 @industries = Industry.order(name: :asc).all
    • Hiếu Lê @hieulh commented Aug 31, 2020

      Industry.order(name: :asc).all anh nghĩ ko cần .all ở cuối

      Edited Aug 31, 2020
      `Industry.order(name: :asc).all` anh nghĩ ko cần `.all` ở cuối
    • Ngô Trung Hưng @hungnt

      changed this line in version 3 of the diff

      Aug 31, 2020

      changed this line in version 3 of the diff

      changed this line in [version 3 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5164&start_sha=5bdd43ef593c94dd247e0cc3d9e1c71551661100#504ab799da80c4c1fdb6316833bcac0b90d13572_34_32)
      Toggle commit list
    Please register or sign in to reply
  • Hiếu Lê
    @hieulh started a discussion on an old version of the diff Aug 31, 2020
    Resolved by Hoang Phuc Do Sep 07, 2020
    config/application.rb
    14 14 config.autoload_paths << Rails.root.join('lib/service')
    15 15 config.autoload_paths << Rails.root.join('lib/src')
    16 16 config.eager_load_paths << Rails.root.join('lib/business')
    17 config.eager_load_paths << Rails.root.join('lib/solr')
    • Hiếu Lê @hieulh commented Aug 31, 2020

      Cả autoload_paths và eager_load_paths Thử viết mỗi loại trên 1 dòng xem. Sau này nếu nhiều folder viết như vậy sẽ khá dài

      Edited Aug 31, 2020
      Cả `autoload_paths` và `eager_load_paths` Thử viết mỗi loại trên 1 dòng xem. Sau này nếu nhiều folder viết như vậy sẽ khá dài
    • Ngô Trung Hưng @hungnt commented Aug 31, 2020
      Master

      dạ anh

      dạ anh
    • Ngô Trung Hưng @hungnt

      changed this line in version 3 of the diff

      Aug 31, 2020

      changed this line in version 3 of the diff

      changed this line in [version 3 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5164&start_sha=5bdd43ef593c94dd247e0cc3d9e1c71551661100#7ff7049c1c8745b54f0a9ef78996f60b38f36268_17_14)
      Toggle commit list
    Please register or sign in to reply
  • Hiếu Lê
    @hieulh started a discussion on an old version of the diff Aug 31, 2020
    Resolved by Ngô Trung Hưng Aug 31, 2020
    lib/solr/solr_setting/solr_server.rb 0 → 100644
    1 # frozen_string_literal: true
    2
    3 module SolrSetting
    4 class SolrServer
    5 URL_SERVER_SOLR = 'http://localhost:8983/solr/venjob'
    • Hiếu Lê @hieulh commented Aug 31, 2020

      Nếu chạy ở nhiều mỗi trường khác nhau, mỗi môi trường là 1 URL khác nhau thì chỗ này fix cứng vậy có ổn ko?

      Nên config những thứ như thế này cho từng môi trường khác nhau. ví dụ: https://github.com/rubyconfig/config

      Edited Aug 31, 2020
      Nếu chạy ở nhiều mỗi trường khác nhau, mỗi môi trường là 1 URL khác nhau thì chỗ này fix cứng vậy có ổn ko? Nên config những thứ như thế này cho từng môi trường khác nhau. ví dụ: https://github.com/rubyconfig/config
    • Ngô Trung Hưng @hungnt

      changed this line in version 3 of the diff

      Aug 31, 2020

      changed this line in version 3 of the diff

      changed this line in [version 3 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5164&start_sha=5bdd43ef593c94dd247e0cc3d9e1c71551661100#0befbf768f55a8b2f35e31f8fffd6618b9c9f645_5_5)
      Toggle commit list
    Please register or sign in to reply
  • Ngô Trung Hưng @hungnt

    added 1 commit

    • 0d67bd1c - factory code function search

    Compare with previous version

    Aug 31, 2020

    added 1 commit

    • 0d67bd1c - factory code function search

    Compare with previous version

    added 1 commit * 0d67bd1c - factory code function search [Compare with previous version](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5164&start_sha=5bdd43ef593c94dd247e0cc3d9e1c71551661100)
    Toggle commit list
  • Hoang Phuc Do
    @phucdh started a discussion on an old version of the diff Aug 31, 2020
    Resolved by Hoang Phuc Do Sep 01, 2020
    app/controllers/search_controller.rb 0 → 100644
    1 class SearchController < ApplicationController
    2 NUMBER_RECORD_IN_PAGE = 10
    3 before_action :load_data_dropdown, only: :multi_search
    4
    5 def multi_search
    6 solr = connect_solr
    7 @keyword = params[:keyword]
    8 @industry = Industry.find_by(id: params[:industry_id]) if params[:industry_id].present?
    9 @city = City.find_by(id: params[:city_id]) if params[:city_id].present?
    10 data = sub_space_params!(params[:keyword], params[:industry_id], params[:city_id])
    11 query = if params[:keyword].blank? && params[:industry_id].blank? && params[:city_id].blank?
    • Hoang Phuc Do @phucdh commented Aug 31, 2020
      Master

      Việc xử lý query ở đây không phải nhiệm vụ của controller, truyền params và đưa phần xử lý này vào lib

      Edited Aug 31, 2020
      Việc xử lý query ở đây không phải nhiệm vụ của controller, truyền params và đưa phần xử lý này vào lib
    • Ngô Trung Hưng @hungnt commented Aug 31, 2020
      Master

      dạ anh

      dạ anh
    • Ngô Trung Hưng @hungnt

      changed this line in version 4 of the diff

      Aug 31, 2020

      changed this line in version 4 of the diff

      changed this line in [version 4 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5168&start_sha=0d67bd1c1f27c5c4de6e1efa70e91c030a9f309a#504ab799da80c4c1fdb6316833bcac0b90d13572_11_8)
      Toggle commit list
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on an old version of the diff Aug 31, 2020
    Resolved by Ngô Trung Hưng Aug 31, 2020
    app/helpers/search_helper.rb 0 → 100644
    1 module SearchHelper
    • Hoang Phuc Do @phucdh commented Aug 31, 2020
      Master

      Không dùng có thể xóa đi

      Edited Aug 31, 2020
      Không dùng có thể xóa đi
    • Ngô Trung Hưng @hungnt

      changed this line in version 4 of the diff

      Aug 31, 2020

      changed this line in version 4 of the diff

      changed this line in [version 4 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5168&start_sha=0d67bd1c1f27c5c4de6e1efa70e91c030a9f309a#343cc1b0fb1c98ff19e9aa46b94b342c981dee00_1_0)
      Toggle commit list
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on the diff Aug 31, 2020
    Resolved by Hoang Phuc Do Sep 07, 2020
    app/controllers/histories_controller.rb
    5 5
    6 6 def index
    7 7 histories = current_user.histories.order(created_at: :desc)
    8 @jobs = histories.map(&:job)
    8 @jobs = histories.map(&:job).compact
    • Hoang Phuc Do @phucdh commented Aug 31, 2020
      Master

      Tại sao cần dùng compact ở đây ?

      Edited Aug 31, 2020
      Tại sao cần dùng compact ở đây ?
    • Ngô Trung Hưng @hungnt commented Aug 31, 2020
      Master

      e sử dụng map nó trả về 1 phần tử cuối cùng là nil nên e dùng compact để bỏ Nil

      e sử dụng map nó trả về 1 phần tử cuối cùng là nil nên e dùng compact để bỏ Nil
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on an old version of the diff Aug 31, 2020
    Resolved by Ngô Trung Hưng Aug 31, 2020
    config/settings/production.yml 0 → 100644
    1 url_server_solr: 'http://.../solr/venjob'
    • Hoang Phuc Do @phucdh commented Aug 31, 2020
      Master

      Thêm dòng trống cuối file

      Edited Aug 31, 2020
      Thêm dòng trống cuối file
    • Ngô Trung Hưng @hungnt

      changed this line in version 4 of the diff

      Aug 31, 2020

      changed this line in version 4 of the diff

      changed this line in [version 4 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5168&start_sha=0d67bd1c1f27c5c4de6e1efa70e91c030a9f309a#9f721df20c484aab6affdcc05c7ac1ca0c5763ea_1_1)
      Toggle commit list
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on an old version of the diff Aug 31, 2020
    Resolved by Ngô Trung Hưng Aug 31, 2020
    app/controllers/search_controller.rb 0 → 100644
    1 class SearchController < ApplicationController
    2 NUMBER_RECORD_IN_PAGE = 10
    • Hoang Phuc Do @phucdh commented Aug 31, 2020
      Master

      Có thế khai báo consntant này trong settings.yml

      Edited Aug 31, 2020
      Có thế khai báo consntant này trong settings.yml
    • Ngô Trung Hưng @hungnt

      changed this line in version 4 of the diff

      Aug 31, 2020

      changed this line in version 4 of the diff

      changed this line in [version 4 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5168&start_sha=0d67bd1c1f27c5c4de6e1efa70e91c030a9f309a#504ab799da80c4c1fdb6316833bcac0b90d13572_2_2)
      Toggle commit list
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on the diff Aug 31, 2020
    Resolved by Hoang Phuc Do Sep 01, 2020
    app/views/home/_banner_and_search.html.erb
    23 22 <h4 class="show_total_job"><%= t('pages.banner.slogan_3', job_count: @job_count) %></h4>
    24 23 <% end %>
    25 24 </div>
    26 <div class="filter_box">
    27 <div class="search_input">
    28 <input type="search" name="" id="" class="custom_input_search" placeholder="<%= t('pages.banner.search_placeholder') %>">
    29 </div>
    30 <div class="search_industries">
    31 <div class="icon_list">
    32 <i class="fa fa-list-ul" aria-hidden="true"></i>
    25 <%= form_with url: search_path, method: :get, local: true, skip_enforcing_utf8: true do |f| %>
    • Hoang Phuc Do @phucdh commented Aug 31, 2020
      Master

      Đối với dạng form không thao tác với ActiveRecord object, tìm hiểu cách sử dụng Form object

      Edited Aug 31, 2020
      Đối với dạng form không thao tác với ActiveRecord object, tìm hiểu cách sử dụng Form object
    • Ngô Trung Hưng @hungnt commented Aug 31, 2020
      Master

      dạ

      dạ
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on an old version of the diff Aug 31, 2020
    Resolved by Hoang Phuc Do Aug 31, 2020
    app/views/search/_block_info_job.html.erb 0 → 100644
    26 <h5 class="box_info_copany_name"><i class="far fa-building"></i> <%= data['company_name'] %></h5>
    27 </div>
    28 <div class="loc">
    29 <h5 class="box_info_location"><i class="fas fa-map-marker-alt"></i>
    30 <%= data['locations'].join(' | ') %>
    31 </h5>
    32 </div>
    33 <h5 class="box_info_salary"><i class="fas fa-dollar-sign"></i>&nbsp;<%= "#{t('pages.index.salary')}: #{data['salary']}" %></h5>
    34 <div class="coc">
    35 <h5 class="box_info_des"><%= strip_tags(data['description']) %></h5>
    36 </div>
    37 </div>
    38 </div>
    39 <div class="col-sm-2 col-md-3 d-none d-sm-block col-lg-2">
    40 <div class="link_favorite_top block_link_favorite">
    41 <% if user_signed_in? %>
    • Hoang Phuc Do @phucdh commented Aug 31, 2020
      Master

      Đoạn này bị lặp với đoạn trên, tách thành một partial để dùng lại

      Edited Aug 31, 2020
      Đoạn này bị lặp với đoạn trên, tách thành một partial để dùng lại
    • Ngô Trung Hưng @hungnt commented Aug 31, 2020
      Master

      Dạ anh

      Dạ anh
    • Ngô Trung Hưng @hungnt

      changed this line in version 4 of the diff

      Aug 31, 2020

      changed this line in version 4 of the diff

      changed this line in [version 4 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5168&start_sha=0d67bd1c1f27c5c4de6e1efa70e91c030a9f309a#0c9b4240a268e8e508bdb13ae14d9af1860fc189_41_32)
      Toggle commit list
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on an old version of the diff Aug 31, 2020
    Resolved by Ngô Trung Hưng Aug 31, 2020
    app/views/search/result.html.erb 0 → 100644
    1 <% provide(:title ,"#{t('pages.detail.br_title')}") %>
    2 <%= render 'home/banner_and_search' %>
    3 <div class="padding_index"></div>
    4 <div class="container">
    5 <div class="row">
    6 <div class="col-lg-12">
    7 <div class="breadcrumb_total_search">
    8 <span class="breadcrumb-item active">
    9 <% if @results.total_count == Job.count %>
    10 <div style="word-wrap: break-word;">
    11 <%= "#{t('pages.result.all')} #{@results.total_count}" %>
    12 </div>
    13 <% elsif @results.total_count > 0 %>
    • Hoang Phuc Do @phucdh commented Aug 31, 2020
      Master

      @results.total_count > 0 => @results.total_count.positive?

      Edited Aug 31, 2020
      `@results.total_count > 0` => `@results.total_count.positive?`
    • Ngô Trung Hưng @hungnt

      changed this line in version 4 of the diff

      Aug 31, 2020

      changed this line in version 4 of the diff

      changed this line in [version 4 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5168&start_sha=0d67bd1c1f27c5c4de6e1efa70e91c030a9f309a#95b2d9d462354f95d554bc5b1510ad5fd5e28ad7_13_13)
      Toggle commit list
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on an old version of the diff Aug 31, 2020
    Resolved by Ngô Trung Hưng Aug 31, 2020
    app/views/search/result.html.erb 0 → 100644
    23 <div class="breadcrumb_total_search_pagination_jobs">
    24 <div class="pagination_jobs">
    25 <div id="paginator">
    26 <%= paginate @results %>
    27 </div>
    28 </div>
    29 </div>
    30 </div>
    31 </div>
    32 </div>
    33 <%= render 'job/modal_login' %>
    34 <%= render partial: 'block_info_job', collection: @results, as: :data %>
    35 <div class="container">
    36 <div class="row">
    37 <div class="col-lg-12">
    38 <div class="breadcrumb_total_search_pagination_jobs">
    • Hoang Phuc Do @phucdh commented Aug 31, 2020
      Master

      Đoạn breadcrumb này cũng bị trùng code, tách thành partial

      Edited Aug 31, 2020
      Đoạn breadcrumb này cũng bị trùng code, tách thành partial
    • Ngô Trung Hưng @hungnt

      changed this line in version 4 of the diff

      Aug 31, 2020

      changed this line in version 4 of the diff

      changed this line in [version 4 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5168&start_sha=0d67bd1c1f27c5c4de6e1efa70e91c030a9f309a#95b2d9d462354f95d554bc5b1510ad5fd5e28ad7_38_29)
      Toggle commit list
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on an old version of the diff Aug 31, 2020
    Resolved by Hoang Phuc Do Aug 31, 2020
    lib/solr/index_data.rb 0 → 100644
    7
    8 def self.indexed(job)
    9 solr = SolrSetting::SolrServer.connection
    10 data = {}
    11 data[:id] = job.id
    12 data[:name] = job.name
    13 data[:company_name] = job.company.name
    14 data[:salary] = job.salary
    15 data[:description] = job.description
    16 data[:industries] = job.industry_jobs.map(&:industry).map(&:name)
    17 data[:industry_id] = job.industry_jobs.map(&:industry_id)
    18 data[:locations] = job.city_jobs.map(&:city).map(&:name)
    19 data[:location_id] = job.city_jobs.map(&:city_id)
    20 solr.add data, add_attributes: {commitWithin: 10}
    21 rescue StandardError => e
    22 logger.error "Indexed data to Solr have error: #{e}"
    • Hoang Phuc Do @phucdh commented Aug 31, 2020
      Master

      logger là một instance method thì cần phải khởi tạo một instance mới dùng được

      Mà trong class method này không thấy chỗ nào tạo insntace.

      Edited Aug 31, 2020
      `logger` là một instance method thì cần phải khởi tạo một instance mới dùng được Mà trong class method này không thấy chỗ nào tạo insntace.
    • Hoang Phuc Do @phucdh commented Aug 31, 2020
      Master

      indexed là một class method

      Nó gọi đến logger là một instance method

      Trong trường hợp nhảy xuống rescue => error

      IndexData.indexed(Job.last)
      NameError (undefined local variable or method `logger' for IndexData:Class)
      Edited Aug 31, 2020 by Hoang Phuc Do
      `indexed` là một class method Nó gọi đến `logger` là một instance method Trong trường hợp nhảy xuống rescue => error ``` IndexData.indexed(Job.last) NameError (undefined local variable or method `logger' for IndexData:Class) ```
    • Ngô Trung Hưng @hungnt commented Aug 31, 2020
      Master

      Cảm ơn anh

      Cảm ơn anh
    • Ngô Trung Hưng @hungnt

      changed this line in version 4 of the diff

      Aug 31, 2020

      changed this line in version 4 of the diff

      changed this line in [version 4 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5168&start_sha=0d67bd1c1f27c5c4de6e1efa70e91c030a9f309a#d27a8561890815503381fb04918893ccd2f61ae4_22_0)
      Toggle commit list
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on an old version of the diff Aug 31, 2020
    Resolved by Ngô Trung Hưng Sep 01, 2020
    lib/solr/index_data.rb 0 → 100644
    1 # frozen_string_literal: true
    2
    3 class IndexData
    4 def logger
    5 @logger ||= Logger.new(Rails.root.join('log', 'indexed_data_to_solr.log'))
    6 end
    7
    8 def self.indexed(job)
    • Hoang Phuc Do @phucdh commented Aug 31, 2020
      Master

      Tên class IndexData là một general name nhưng implement lại chỉ dành cho job

      Thay vì truyền trực tiếp object job vào đây, thì có thể tìm hiểu cách khác cho dễ mở rộng hơn nhé

      keyword: Strategy pattern

      Edited Sep 01, 2020
      Tên class `IndexData` là một general name nhưng implement lại chỉ dành cho job Thay vì truyền trực tiếp object job vào đây, thì có thể tìm hiểu cách khác cho dễ mở rộng hơn nhé keyword: Strategy pattern
    • Ngô Trung Hưng @hungnt

      changed this line in version 4 of the diff

      Aug 31, 2020

      changed this line in version 4 of the diff

      changed this line in [version 4 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5168&start_sha=0d67bd1c1f27c5c4de6e1efa70e91c030a9f309a#d27a8561890815503381fb04918893ccd2f61ae4_8_0)
      Toggle commit list
    Please register or sign in to reply
  • Ngô Trung Hưng @hungnt

    added 1 commit

    • 612b302e - use Strategy pattern

    Compare with previous version

    Aug 31, 2020

    added 1 commit

    • 612b302e - use Strategy pattern

    Compare with previous version

    added 1 commit * 612b302e - use Strategy pattern [Compare with previous version](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5168&start_sha=0d67bd1c1f27c5c4de6e1efa70e91c030a9f309a)
    Toggle commit list
  • Ngô Trung Hưng @hungnt

    added 1 commit

    • 202b4d6d - edit gitignore

    Compare with previous version

    Aug 31, 2020

    added 1 commit

    • 202b4d6d - edit gitignore

    Compare with previous version

    added 1 commit * 202b4d6d - edit gitignore [Compare with previous version](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5169&start_sha=612b302eedc309d8c1307266a8222912d7614028)
    Toggle commit list
  • Ngô Trung Hưng @hungnt

    added 1 commit

    • 4e3ee992 - use form object

    Compare with previous version

    Sep 01, 2020

    added 1 commit

    • 4e3ee992 - use form object

    Compare with previous version

    added 1 commit * 4e3ee992 - use form object [Compare with previous version](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5172&start_sha=202b4d6d9ecf6de9ee14f9a7946ae16595acbf2e)
    Toggle commit list
  • Hoang Phuc Do
    @phucdh started a discussion on commit 4e3ee992 Sep 01, 2020
    Last updated by Ngô Trung Hưng Sep 01, 2020
    app/forms/send_data_to_apply_form.rb 0 → 100644
    1 # frozen_string_literal: true
    2
    3 class SendDataToApplyForm
    • Hoang Phuc Do @phucdh commented Sep 01, 2020
      Master

      Sử dụng danh từ để đặt tên cho class name

      Sử dụng danh từ để đặt tên cho class name
    • Ngô Trung Hưng @hungnt commented Sep 01, 2020
      Master

      Dạ anh

      Dạ anh
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on commit 4e3ee992 Sep 01, 2020
    app/controllers/search_controller.rb
    2 2 before_action :load_data_dropdown
    3 3
    4 4 def search
    5 @keyword = params[:keyword]
    5 debugger
    6 @keyword = params[:send_data_to_apply_form][:keyword]
    6 7 @industry = Industry.find_by(id: params[:industry_id]) if params[:industry_id].present?
    7 8 @city = City.find_by(id: params[:city_id]) if params[:city_id].present?
    8 @results = Search::Query.new.search(params[:keyword], params[:industry_id], params[:city_id], params[:page])
    9 @results = Search::Query.new.search(@keyword, params[:industry_id], params[:city_id], params[:page])
    • Hoang Phuc Do @phucdh commented Sep 01, 2020
      Master

      Truyền trực tiếp params vào thì có vấn đề gì không ?

      Vd :

      Search::Query.new.search(params)
      Truyền trực tiếp params vào thì có vấn đề gì không ? Vd : ```ruby Search::Query.new.search(params) ```
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on commit 4e3ee992 Sep 01, 2020
    app/controllers/home_controller.rb
    3 3 # Home page
    4 4 class HomeController < ApplicationController
    5 5 def index
    6 @search = SendDataToApplyForm.new
    6 7 @industries = Industry.order(name: :asc).all
    • Hoang Phuc Do @phucdh commented Sep 01, 2020
      Master

      Có cần #all ở đây không ?

      Có cần `#all` ở đây không ?
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on commit 4e3ee992 Sep 01, 2020
    app/views/search/_new.html.erb 0 → 100644
    1 <div class = "box-banner">
    • Hoang Phuc Do @phucdh commented Sep 01, 2020
      Master

      Thẻ class sao bị khoảng trắng thế này ?

      Thẻ `class` sao bị khoảng trắng thế này ?
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on commit 4e3ee992 Sep 01, 2020
    app/views/search/_new.html.erb 0 → 100644
    5 <div class = "slogan">
    6 <h2 class = "slogan_text">
    7 <%= t('pages.banner.slogan') %>
    8 </h2>
    9 <h5 class = "slogan_text_h5">
    10 <%= t('pages.banner.slogan') %>
    11 </h5>
    12 </div>
    13 </div>
    14 </div>
    15 <!-- Process search pc-->
    16 <div class="box-search">
    17 <div class="search_scaffold">
    18 <div class = "total_job">
    19 <% if @job_count.blank? %>
    20 <h4 class="show_total_job"><%= t('pages.banner.slogan_2') %></h4>
    • Hoang Phuc Do @phucdh commented Sep 01, 2020
      Master

      Giữ lại phần cố định, tách phần thay đổi.

      <h4 class="show_total_job">
        <%= @job_count.blank? ? t('pages.banner.slogan_2') : t('pages.banner.slogan_3', job_count: @job_count) %>
      </h4>
      Giữ lại phần cố định, tách phần thay đổi. ```ruby <h4 class="show_total_job"> <%= @job_count.blank? ? t('pages.banner.slogan_2') : t('pages.banner.slogan_3', job_count: @job_count) %> </h4> ```
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on commit 4e3ee992 Sep 01, 2020
    app/views/search/_new.html.erb 0 → 100644
    27 <div class="search_input">
    28 <%= f.search_field :keyword, value: @keyword, class: 'custom_input_search', placeholder: t('pages.banner.search_placeholder') %>
    29 </div>
    30 <div class="search_industries">
    31 <div class="icon_list">
    32 <i class="fa fa-list-ul" aria-hidden="true"></i>
    33 </div>
    34 <% selected = @industry.blank? ? '*' : @industry.id %>
    35 <%= select_tag 'industry_id', options_from_collection_for_select(@industries, 'id', 'name', selected), prompt: t('pages.banner.all_industries'), class: 'show_list_industries' %>
    36 </div>
    37 <div class="search_location">
    38 <div class="icon_list">
    39 <i class="fas fa-map-marker-alt"></i>
    40 </div>
    41 <% selected = @city.blank? ? '*' : @city.id %>
    42 <%= select_tag 'city_id', options_from_collection_for_select(@cities, 'id', 'name', selected), prompt: t('pages.banner.all_locations'), class: 'show_list_cities' %>
    • Hoang Phuc Do @phucdh commented Sep 01, 2020
      Master

      Sử dụng #select của form_for

      Sử dụng `#select` của `form_for`
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on commit 4e3ee992 Sep 01, 2020
    app/views/search/_new.html.erb 0 → 100644
    26 <div class="filter_box">
    27 <div class="search_input">
    28 <%= f.search_field :keyword, value: @keyword, class: 'custom_input_search', placeholder: t('pages.banner.search_placeholder') %>
    29 </div>
    30 <div class="search_industries">
    31 <div class="icon_list">
    32 <i class="fa fa-list-ul" aria-hidden="true"></i>
    33 </div>
    34 <% selected = @industry.blank? ? '*' : @industry.id %>
    35 <%= select_tag 'industry_id', options_from_collection_for_select(@industries, 'id', 'name', selected), prompt: t('pages.banner.all_industries'), class: 'show_list_industries' %>
    36 </div>
    37 <div class="search_location">
    38 <div class="icon_list">
    39 <i class="fas fa-map-marker-alt"></i>
    40 </div>
    41 <% selected = @city.blank? ? '*' : @city.id %>
    • Hoang Phuc Do @phucdh commented Sep 01, 2020
      Master

      Đưa phần xử lý logic vào Form object

      Đưa phần xử lý logic vào Form object
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on an old version of the diff Sep 01, 2020
    Resolved by Ngô Trung Hưng Sep 01, 2020
    config/routes.rb
    3 3 Rails.application.routes.draw do
    4 4 get 'setting', to: 'users#set_lang', as: :set_lang
    5 5 scope '(:locale)', locale: /en|vi/ do
    6 devise_for :users, controllers: { registrations: 'registrations' }
    6 devise_for :users, controllers: { registrations: 'registrations', passwords: 'passwords'}
    7 7 root 'home#index'
    8 # Search
    9 get 'search', to: 'search#search', as: :send_data_to_apply_forms
    • Hoang Phuc Do @phucdh commented Sep 01, 2020
      Master

      Chỗ này hình như bị trùng ?

      Edited Sep 01, 2020
      Chỗ này hình như bị trùng ?
    • Ngô Trung Hưng @hungnt

      changed this line in version 7 of the diff

      Sep 01, 2020

      changed this line in version 7 of the diff

      changed this line in [version 7 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5175&start_sha=4e3ee99201ba3412272e776a8c14ba19a7f8c7b2#e801163eb9182955dca3eb9817d59af634f6665d_9_9)
      Toggle commit list
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on an old version of the diff Sep 01, 2020
    Resolved by Hoang Phuc Do Sep 07, 2020
    app/views/search/result.html.erb 0 → 100644
    2 <%= render 'home/banner_and_search' %>
    3 <div class="padding_index"></div>
    4 <div class="container">
    5 <div class="row">
    6 <div class="col-lg-12">
    7 <div class="breadcrumb_total_search">
    8 <span class="breadcrumb-item active">
    9 <% if @results.total_count == Job.count %>
    10 <div style="word-wrap: break-word;">
    11 <%= "#{t('pages.result.all')} #{@results.total_count}" %>
    12 </div>
    13 <% elsif @results.total_count.positive? %>
    14 <%= t('pages.result.result_find', job: @results.total_count, key: @keyword).html_safe %>
    15 <% else %>
    16 <%= t('pages.result.no_result_find', key: @keyword).html_safe %>
    17 <% end %>
    • Hoang Phuc Do @phucdh commented Sep 01, 2020
      Master

      Canh lại indent

      Edited Sep 01, 2020
      Canh lại indent
    • Ngô Trung Hưng @hungnt commented Sep 01, 2020
      Master

      dạ anh

      dạ anh
    • Ngô Trung Hưng @hungnt

      changed this line in version 7 of the diff

      Sep 01, 2020

      changed this line in version 7 of the diff

      changed this line in [version 7 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5175&start_sha=4e3ee99201ba3412272e776a8c14ba19a7f8c7b2#95b2d9d462354f95d554bc5b1510ad5fd5e28ad7_17_17)
      Toggle commit list
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on an old version of the diff Sep 01, 2020
    Resolved by Hoang Phuc Do Sep 07, 2020
    lib/solr/search/query.rb 0 → 100644
    1 module Search
    2 class Query
    3 def search(keyword, industry_id, city_id, params_page)
    4 solr = connect_solr
    5 # Escape input & Convert space to asterisks
    6 data = sub_space_params!(keyword, industry_id, city_id)
    7 query = if keyword.blank? && industry_id.blank? && city_id.blank?
    8 '*:*'
    9 else
    10 "solr((name: #{data[:keyword]}) OR (company_name: #{data[:keyword]})) AND (industry_id: #{data[:industry_id]}) AND (location_id: #{data[:location_id]})"
    • Hoang Phuc Do @phucdh commented Sep 01, 2020
      Master

      Trường hợp 1 trong 3 cái keyword, industry_id, city_id bị blank thì sao ?

      Edited Sep 01, 2020
      Trường hợp 1 trong 3 cái `keyword, industry_id, city_id` bị blank thì sao ?
    • Ngô Trung Hưng @hungnt commented Sep 01, 2020
      Master

      1 trong 3 cái blank nó vẫn nhảy xuống case 2 anh

      1 trong 3 cái blank nó vẫn nhảy xuống case 2 anh
    • Ngô Trung Hưng @hungnt

      changed this line in version 7 of the diff

      Sep 01, 2020

      changed this line in version 7 of the diff

      changed this line in [version 7 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5175&start_sha=4e3ee99201ba3412272e776a8c14ba19a7f8c7b2#fbe67f986cceee28a36218e8d9d89474818dc3d8_10_0)
      Toggle commit list
    Please register or sign in to reply
  • Ngô Trung Hưng @hungnt

    added 1 commit

    • 8d2405f1 - fix func search

    Compare with previous version

    Sep 01, 2020

    added 1 commit

    • 8d2405f1 - fix func search

    Compare with previous version

    added 1 commit * 8d2405f1 - fix func search [Compare with previous version](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5175&start_sha=4e3ee99201ba3412272e776a8c14ba19a7f8c7b2)
    Toggle commit list
  • Hoang Phuc Do
    @phucdh started a discussion on an old version of the diff Sep 07, 2020
    Resolved by Ngô Trung Hưng Sep 07, 2020
    lib/solr/searches/query.rb 0 → 100644
    1 module Searches
    2 class Query
    3 def search(params)
    4 solr = connect_solr
    5 # Escape input & Convert space to asterisks
    6 data = sub_space_params!(params[:search][:keyword], params[:search][:industry_id], params[:search][:city_id])
    7 query = if [params[:search][:keyword], params[:search][:industry_id], params[:search][:city_id]].all? { |v| v.blank?}
    8 '*:*'
    9 else
    10 "solr((name: #{data[:keyword]}) OR (company_name: #{data[:keyword]})) AND (industry_id: #{data[:industry_id]}) AND (location_id: #{data[:location_id]})"
    11 end
    12 response = solr.paginate(params[:page], Settings.number_result_search_in_page, 'select', params: { q: query })
    13 results = Kaminari.paginate_array(response['response']['docs'], total_count: response['response']['numFound']).page(params[:page]).per(Settings.number_result_search_in_page)
    • Hoang Phuc Do @phucdh commented Sep 07, 2020
      Master

      Việc gán biến ở đây không cần thiết

      Edited Sep 07, 2020
      Việc gán biến ở đây không cần thiết
    • Ngô Trung Hưng @hungnt

      changed this line in version 8 of the diff

      Sep 07, 2020

      changed this line in version 8 of the diff

      changed this line in [version 8 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5186&start_sha=8d2405f10daf417687f1c5f1febcd2639614898f#6691544705179ec4509fd071e62f0ceae29e22cf_13_15)
      Toggle commit list
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on an old version of the diff Sep 07, 2020
    Resolved by Ngô Trung Hưng Sep 07, 2020
    lib/solr/searches/query.rb 0 → 100644
    3 def search(params)
    4 solr = connect_solr
    5 # Escape input & Convert space to asterisks
    6 data = sub_space_params!(params[:search][:keyword], params[:search][:industry_id], params[:search][:city_id])
    7 query = if [params[:search][:keyword], params[:search][:industry_id], params[:search][:city_id]].all? { |v| v.blank?}
    8 '*:*'
    9 else
    10 "solr((name: #{data[:keyword]}) OR (company_name: #{data[:keyword]})) AND (industry_id: #{data[:industry_id]}) AND (location_id: #{data[:location_id]})"
    11 end
    12 response = solr.paginate(params[:page], Settings.number_result_search_in_page, 'select', params: { q: query })
    13 results = Kaminari.paginate_array(response['response']['docs'], total_count: response['response']['numFound']).page(params[:page]).per(Settings.number_result_search_in_page)
    14 end
    15
    16 def sub_space_params!(keyword, industry_id, location_id)
    17 arr_params = {}
    18 arr_params[:keyword] = RSolr.solr_escape(keyword)
    • Hoang Phuc Do @phucdh commented Sep 07, 2020
      Master

      Trường hợp các params keyword, industry_id, location_id bị nil thì sẽ xảy ra lỗi ở đây

      Edited Sep 07, 2020
      Trường hợp các params `keyword, industry_id, location_id` bị `nil` thì sẽ xảy ra lỗi ở đây
    • Ngô Trung Hưng @hungnt

      changed this line in version 8 of the diff

      Sep 07, 2020

      changed this line in version 8 of the diff

      changed this line in [version 8 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5186&start_sha=8d2405f10daf417687f1c5f1febcd2639614898f#6691544705179ec4509fd071e62f0ceae29e22cf_18_20)
      Toggle commit list
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on an old version of the diff Sep 07, 2020
    Resolved by Ngô Trung Hưng Sep 07, 2020
    lib/solr/sync/entities/job.rb 0 → 100644
    1 # frozen_string_literal: true
    2
    3 module Sync::Entities
    4 class Job < Sync::Entities::Base
    5 def to_h
    6 data = {}
    7 data[:id] = job.id
    8 data[:name] = job.name
    9 data[:company_name] = job.company.name
    10 data[:salary] = job.salary
    11 data[:description] = job.description
    12 data[:industries] = job.industry_jobs.map(&:industry).map(&:name)
    • Hoang Phuc Do @phucdh commented Sep 07, 2020
      Master

      job.industry_jobs.map(&:industry).map(&:name) => jobs.industries.pluck(:name)

      Sửa lại những chỗ tương tự

      Edited Sep 07, 2020
      `job.industry_jobs.map(&:industry).map(&:name)` => `jobs.industries.pluck(:name)` Sửa lại những chỗ tương tự
    • Ngô Trung Hưng @hungnt

      changed this line in version 8 of the diff

      Sep 07, 2020

      changed this line in version 8 of the diff

      changed this line in [version 8 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5186&start_sha=8d2405f10daf417687f1c5f1febcd2639614898f#8f255893d01e3192d48311bc8c51a224d04f7343_12_12)
      Toggle commit list
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on an old version of the diff Sep 07, 2020
    Resolved by Ngô Trung Hưng Sep 07, 2020
    lib/solr/sync/entities/job.rb 0 → 100644
    1 # frozen_string_literal: true
    2
    3 module Sync::Entities
    4 class Job < Sync::Entities::Base
    5 def to_h
    6 data = {}
    7 data[:id] = job.id
    8 data[:name] = job.name
    9 data[:company_name] = job.company.name
    10 data[:salary] = job.salary
    11 data[:description] = job.description
    12 data[:industries] = job.industry_jobs.map(&:industry).map(&:name)
    13 data[:industry_id] = job.industry_jobs.map(&:industry_id)
    14 data[:locations] = job.city_jobs.map(&:city).map(&:name)
    • Hoang Phuc Do @phucdh commented Sep 07, 2020
      Master

      job.city_jobs.map(&:city).map(&:name) => job.cities.pluck(:name)

      Sửa lại những chỗ tương tự

      Edited Sep 07, 2020
      `job.city_jobs.map(&:city).map(&:name)` => `job.cities.pluck(:name)` Sửa lại những chỗ tương tự
    • Ngô Trung Hưng @hungnt

      changed this line in version 8 of the diff

      Sep 07, 2020

      changed this line in version 8 of the diff

      changed this line in [version 8 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5186&start_sha=8d2405f10daf417687f1c5f1febcd2639614898f#8f255893d01e3192d48311bc8c51a224d04f7343_14_14)
      Toggle commit list
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on an old version of the diff Sep 07, 2020
    Resolved by Hoang Phuc Do Sep 07, 2020
    lib/service/import_data.rb
    43 43 industry_name = val['category'].gsub(',', '/').gsub('/', ' / ')
    44 44 industry = Industry.find_or_create_by(name: industry_name.strip)
    45 45
    46 Job.find_or_create_by(name: val['name'], company_id: company_id) do |job|
    46 record = Job.find_or_initialize_by(name: val['name'], company_id: company_id) do |job|
    47 47 job.level = val['level']
    48 48 job.salary = val['salary']
    49 49 job.description = desc
    50 50 job.city_ids.blank? ? job.cities << city : job.cities == city
    51 51 job.industry_ids.blank? ? job.industries << industry : job.industries == industry
    52 52 end
    53 if record.new_record?
    54 record.save
    55 index_strategy = Sync::Entities::Job.new(record)
    • Hoang Phuc Do @phucdh commented Sep 07, 2020
      Master
      index_strategy = Sync::Entities::Job.new(record)
      Sync::Indexer.new.do(index_strategy)

      Đoạn này đang bị lặp, có thể refactor lại bằng cách sử dụng Observer pattern

      ```ruby index_strategy = Sync::Entities::Job.new(record) Sync::Indexer.new.do(index_strategy) ``` Đoạn này đang bị lặp, có thể refactor lại bằng cách sử dụng Observer pattern
    • Ngô Trung Hưng @hungnt

      changed this line in version 8 of the diff

      Sep 07, 2020

      changed this line in version 8 of the diff

      changed this line in [version 8 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5186&start_sha=8d2405f10daf417687f1c5f1febcd2639614898f#fb47c56e27671d261a144b62e44604e1e9e53666_55_55)
      Toggle commit list
    Please register or sign in to reply
  • Ngô Trung Hưng @hungnt

    added 1 commit

    • edd8e6cc - fix method sub_space_params!

    Compare with previous version

    Sep 07, 2020

    added 1 commit

    • edd8e6cc - fix method sub_space_params!

    Compare with previous version

    added 1 commit * edd8e6cc - fix method sub_space_params! [Compare with previous version](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5186&start_sha=8d2405f10daf417687f1c5f1febcd2639614898f)
    Toggle commit list
  • Hoang Phuc Do
    @phucdh started a discussion on the diff Sep 07, 2020
    Resolved by Ngô Trung Hưng Sep 08, 2020
    lib/service/import_data.rb
    43 43 industry_name = val['category'].gsub(',', '/').gsub('/', ' / ')
    44 44 industry = Industry.find_or_create_by(name: industry_name.strip)
    45 45
    46 Job.find_or_create_by(name: val['name'], company_id: company_id) do |job|
    46 record = Job.find_or_initialize_by(name: val['name'], company_id: company_id) do |job|
    47 47 job.level = val['level']
    48 48 job.salary = val['salary']
    49 49 job.description = desc
    50 50 job.city_ids.blank? ? job.cities << city : job.cities == city
    51 51 job.industry_ids.blank? ? job.industries << industry : job.industries == industry
    52 52 end
    53 if record.new_record?
    54 record.save
    55 IndexedJob.new(job).do
    • Hoang Phuc Do @phucdh commented Sep 07, 2020
      Master

      Trường hợp mà một thông tin bất kì của job, vd: salary, description thay đổi thì cũng nên được sync lại lên Solr

      Edited Sep 08, 2020
      Trường hợp mà một thông tin bất kì của job, vd: salary, description thay đổi thì cũng nên được sync lại lên Solr
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on the diff Sep 07, 2020
    Resolved by Ngô Trung Hưng Sep 07, 2020
    app/controllers/search_controller.rb 0 → 100644
    1 class SearchController < ApplicationController
    2 before_action :load_data_dropdown
    3
    4 def search
    5 @keyword = params[:search][:keyword]
    • Hoang Phuc Do @phucdh commented Sep 07, 2020
      Master

      Trường hợp params[:search] là nil thì sẽ báo lỗi ở đây

      URL bị lỗi: http://localhost:1234/vi/search

      Edited Sep 07, 2020
      Trường hợp `params[:search]` là `nil` thì sẽ báo lỗi ở đây URL bị lỗi: http://localhost:1234/vi/search
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on an old version of the diff Sep 07, 2020
    Resolved by Hoang Phuc Do Sep 09, 2020
    lib/solr/searches/query.rb 0 → 100644
    1 # frozen_string_literal: true
    2
    3 module Searches
    4 class Query
    5 def search(params)
    6 solr = connect_solr
    7 # Escape input & Convert space to asterisks
    8 data = sub_space_params!(params[:search][:keyword], params[:search][:industry_id], params[:search][:city_id])
    9 query = if [params[:search][:keyword], params[:search][:industry_id], params[:search][:city_id]].all?(&:blank?)
    10 '*:*'
    11 else
    12 "solr((name: #{data[:keyword]}) OR (company_name: #{data[:keyword]})) AND (industry_id: #{data[:industry_id]}) AND (location_id: #{data[:location_id]})"
    • Hoang Phuc Do @phucdh commented Sep 07, 2020
      Master

      Bị lỗi khi thử tìm kiếm với keyword: AND company_name: abc

      Mở rộng, nếu chỉ có params[:search][:keyword] có giá trị, thì có thể tìm keyword trong tất cả các field text chứ không cần giới hạn trong field name

      Edited Sep 09, 2020
      Bị lỗi khi thử tìm kiếm với keyword: `AND company_name: abc` Mở rộng, nếu chỉ có `params[:search][:keyword]` có giá trị, thì có thể tìm keyword trong tất cả các field text chứ không cần giới hạn trong field `name`
    • Ngô Trung Hưng @hungnt

      changed this line in version 9 of the diff

      Sep 08, 2020

      changed this line in version 9 of the diff

      changed this line in [version 9 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5189&start_sha=edd8e6ccbd292293a4b5a7e5714608c3d2d20d66#6691544705179ec4509fd071e62f0ceae29e22cf_12_12)
      Toggle commit list
    Please register or sign in to reply
  • Ngô Trung Hưng @hungnt

    added 1 commit

    • 56fa3250 - refactor code function search

    Compare with previous version

    Sep 08, 2020

    added 1 commit

    • 56fa3250 - refactor code function search

    Compare with previous version

    added 1 commit * 56fa3250 - refactor code function search [Compare with previous version](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5189&start_sha=edd8e6ccbd292293a4b5a7e5714608c3d2d20d66)
    Toggle commit list
  • Hoang Phuc Do
    @phucdh started a discussion on an old version of the diff Sep 09, 2020
    Last updated by Ngô Trung Hưng Sep 09, 2020
    lib/solr/searches/query.rb 0 → 100644
    6 solr = connect_solr
    7 # Escape input & Convert space to asterisks
    8 data = sub_space_params!(params[:search][:keyword], params[:search][:industry_id], params[:search][:city_id])
    9 query = if [params[:search][:keyword], params[:search][:industry_id], params[:search][:city_id]].all?(&:blank?)
    10 '*:*'
    11 else
    12 "#{data[:keyword]} AND (industry_id: #{data[:industry_id]}) AND (location_id: #{data[:location_id]})"
    13 end
    14 response = solr.paginate(params[:page], Settings.number_result_search_in_page, 'select', params: { q: query })
    15 Kaminari.paginate_array(response['response']['docs'], total_count: response['response']['numFound']).page(params[:page]).per(Settings.number_result_search_in_page)
    16 end
    17
    18 def sub_space_params!(keyword, industry_id, location_id)
    19 arr_params = {}
    20 arr_params[:keyword] = RSolr.solr_escape(keyword.downcase || '')
    21 arr_params[:industry_id] = RSolr.solr_escape(industry_id || '')
    • Hoang Phuc Do @phucdh commented Sep 09, 2020
      Master

      Nếu thay các keyword đặc biệt vào url của browser thì lỗi sẽ xuất hiện

      http://localhost:1234/vi/search?search[keyword]=AND+b&search[industry_id]=AND+b&search[city_id]=

      Tất cả params nhận từ user đều cần được validate nhiều trường hợp nhất có thể

      Nếu thay các keyword đặc biệt vào url của browser thì lỗi sẽ xuất hiện http://localhost:1234/vi/search?search[keyword]=AND+b&search[industry_id]=AND+b&search[city_id]= Tất cả params nhận từ user đều cần được validate nhiều trường hợp nhất có thể
    • Ngô Trung Hưng @hungnt

      changed this line in version 11 of the diff

      Sep 09, 2020

      changed this line in version 11 of the diff

      changed this line in [version 11 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5197&start_sha=f5cac5505d89bdb7d0c6ea728c1ac0971b8a8c9d#6691544705179ec4509fd071e62f0ceae29e22cf_21_21)
      Toggle commit list
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on an old version of the diff Sep 09, 2020
    Resolved by Ngô Trung Hưng Sep 09, 2020
    app/controllers/search_controller.rb 0 → 100644
    1 class SearchController < ApplicationController
    2 before_action :load_data_dropdown
    3
    4 def search
    5 return render 'error/internal_server_error' if params[:search].blank?
    6 @keyword = params[:search][:keyword]
    7 @industry = Industry.find_by(id: params[:search][:industry_id])
    8 @city = City.find_by(id: params[:search][:city_id])
    9 @results = Searches::Query.new.search(params)
    10 return render 'error/page_not_found' if params[:page].to_i > @results.total_pages
    11 @search = Search.new
    • Hoang Phuc Do @phucdh commented Sep 09, 2020
      Master

      Truyền params vào form search giống như đang xử lý một ActiveRecord

      Vd:

      def search
        @search = Search.new(search_params)
      end
      
      def search_params
        # Your code
      end
      Edited Sep 09, 2020
      Truyền params vào form search giống như đang xử lý một ActiveRecord Vd: ```ruby def search @search = Search.new(search_params) end def search_params # Your code end ```
    • Ngô Trung Hưng @hungnt

      changed this line in version 10 of the diff

      Sep 09, 2020

      changed this line in version 10 of the diff

      changed this line in [version 10 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5195&start_sha=56fa3250f07a1a30516c15edbf8bbe98e60bebc3#504ab799da80c4c1fdb6316833bcac0b90d13572_11_12)
      Toggle commit list
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on an old version of the diff Sep 09, 2020
    Resolved by Ngô Trung Hưng Sep 09, 2020
    app/controllers/home_controller.rb
    3 3 # Home page
    4 4 class HomeController < ApplicationController
    5 5 def index
    6 @industries = Industry.order(name: :asc).all
    6 @search = Search.new
    • Hoang Phuc Do @phucdh commented Sep 09, 2020
      Master

      Khởi tạo Search được dùng ở nhiều nơi thì nên khai báo vào một chỗ để dùng chung

      Edited Sep 09, 2020
      Khởi tạo `Search` được dùng ở nhiều nơi thì nên khai báo vào một chỗ để dùng chung
    • Ngô Trung Hưng @hungnt

      changed this line in version 10 of the diff

      Sep 09, 2020

      changed this line in version 10 of the diff

      changed this line in [version 10 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5195&start_sha=56fa3250f07a1a30516c15edbf8bbe98e60bebc3#559869901c694d8d8f52f93007c8b250a14147f0_6_7)
      Toggle commit list
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on an old version of the diff Sep 09, 2020
    Resolved by Ngô Trung Hưng Sep 09, 2020
    app/controllers/home_controller.rb
    3 3 # Home page
    4 4 class HomeController < ApplicationController
    5 5 def index
    6 @industries = Industry.order(name: :asc).all
    6 @search = Search.new
    • Hoang Phuc Do @phucdh commented Sep 09, 2020
      Master

      Khởi tạo Search được dùng ở nhiều nơi thì nên khai báo vào một chỗ để dùng chung

      Edited Sep 09, 2020
      Khởi tạo `Search` được dùng ở nhiều nơi thì nên khai báo vào một chỗ để dùng chung
    • Ngô Trung Hưng @hungnt

      changed this line in version 10 of the diff

      Sep 09, 2020

      changed this line in version 10 of the diff

      changed this line in [version 10 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5195&start_sha=56fa3250f07a1a30516c15edbf8bbe98e60bebc3#559869901c694d8d8f52f93007c8b250a14147f0_6_7)
      Toggle commit list
    Please register or sign in to reply
  • Hoang Phuc Do
    @phucdh started a discussion on an old version of the diff Sep 09, 2020
    Resolved by Ngô Trung Hưng Sep 09, 2020
    app/views/home/index.html.erb
    1 1 <% provide(:title, "#{t('title.home')}") %>
    2 <%= render 'home/banner_and_search' %>
    2 <%= render 'search/banner_and_search' %>
    3 3 <div class="padding_index"></div>
    4 4 <% unless @job_count.nil? %>
    • Hoang Phuc Do @phucdh commented Sep 09, 2020
      Master

      Trường hợp nào thì @job_count có giá trị nil ?

      Edited Sep 09, 2020
      Trường hợp nào thì `@job_count` có giá trị `nil` ?
    • Ngô Trung Hưng @hungnt

      changed this line in version 10 of the diff

      Sep 09, 2020

      changed this line in version 10 of the diff

      changed this line in [version 10 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5195&start_sha=56fa3250f07a1a30516c15edbf8bbe98e60bebc3#3bf63da9a86734af839552d26556a28fb7456f0c_4_4)
      Toggle commit list
    Please register or sign in to reply
  • Ngô Trung Hưng @hungnt

    added 1 commit

    • f5cac550 - validate params search

    Compare with previous version

    Sep 09, 2020

    added 1 commit

    • f5cac550 - validate params search

    Compare with previous version

    added 1 commit * f5cac550 - validate params search [Compare with previous version](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5195&start_sha=56fa3250f07a1a30516c15edbf8bbe98e60bebc3)
    Toggle commit list
  • Ngô Trung Hưng @hungnt

    added 1 commit

    • 25cfc16c - fix methods sub_space_params

    Compare with previous version

    Sep 09, 2020

    added 1 commit

    • 25cfc16c - fix methods sub_space_params

    Compare with previous version

    added 1 commit * 25cfc16c - fix methods sub_space_params [Compare with previous version](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5197&start_sha=f5cac5505d89bdb7d0c6ea728c1ac0971b8a8c9d)
    Toggle commit list
  • Ngô Trung Hưng @hungnt

    added 1 commit

    • ec198c36 - delete folder .vscode

    Compare with previous version

    Sep 10, 2020

    added 1 commit

    • ec198c36 - delete folder .vscode

    Compare with previous version

    added 1 commit * ec198c36 - delete folder .vscode [Compare with previous version](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/15/diffs?diff_id=5200&start_sha=25cfc16c407f532ef1dcca18c63bd1b849a154f9)
    Toggle commit list
  • Hoang Phuc Do @phucdh

    mentioned in commit a7f6755d

    Sep 10, 2020

    mentioned in commit a7f6755d

    mentioned in commit a7f6755df19a4b01ac5c94ef867faa357219cc9f
    Toggle commit list
  • Hoang Phuc Do @phucdh

    merged

    Sep 10, 2020

    merged

    merged
    Toggle commit list
  • Write
  • Preview
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 sign in to comment
Assignee
No assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
3
3 participants
Reference: hungnt/venjob_nth!15
×

Revert this merge request

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.
×

Cherry-pick this merge request

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.