Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
  • This project
    • Loading...
  • Sign in / Register
V
VeNJOB
  • 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 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Wiki
    • Wiki
  • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Nguyen Ngoc Nghia
  • VeNJOB
  • Merge Requests
  • !20

Merged
Opened Feb 17, 2020 by Nguyen Ngoc Nghia@nghiann 
  • Report abuse
Report abuse

Feature/search function

  • Search jobs in both English and Vietnamese.
  • Now can search for jobs or query by city/industry.
  • All jobs have been indexed on Solr.

search_1 search_2 query_by_city

Edited Feb 20, 2020 by Nguyen Ngoc Nghia
×

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_function origin/feature/search_function

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_function

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 9
  • Commits 11
  • Changes 10
{{ resolvedDiscussionCount }}/{{ discussionCount }} {{ resolvedCountText }} resolved
  • Van Hau Le
    @haulv started a discussion on an old version of the diff Feb 17, 2020
    Automatically resolved by Nguyen Ngoc Nghia with a push Feb 18, 2020
    app/controllers/jobs_controller.rb
    3 3 before_action :find_user, only: :apply_available
    4 4
    5 5 def index
    6 @search = params[:search] || ":"
    6 7 if params[:city_id]
    7 8 @city = City.find(params[:city_id])
    8 9 @jobs = @city.jobs
    10 @jobs = @jobs.page(params[:page]).per(Settings.job.per_page).decorate
    9 11 elsif params[:industry_id]
    10 12 @industry = Industry.find(params[:industry_id])
    11 13 @jobs = @industry.jobs
    14 @jobs = @jobs.page(params[:page]).per(Settings.job.per_page).decorate
    12 15 else
    13 @jobs = Job.all
    16 @jobs_count = SolrService.new.search(@search)["numFound"]
    • Van Hau Le @haulv commented Feb 17, 2020
      Master

      @nghiann call SolrService.new.search(@search) 1 lần, rồi get numFound với docs tương ứng! không call 2 lần nhé!

      @nghiann call `SolrService.new.search(@search)` 1 lần, rồi get `numFound` với `docs` tương ứng! không call 2 lần nhé!
    • Nguyen Ngoc Nghia @nghiann

      changed this line in version 2 of the diff

      Feb 18, 2020

      changed this line in version 2 of the diff

      changed this line in [version 2 of the diff](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/20/diffs?diff_id=4692&start_sha=b7e99753167760f62e25a0300371627e0bbe92f2#6fa69a07843a58f190bf4d7e0692b9cc5b0bf52b_16_20)
      Toggle commit list
    Please register or sign in to reply
  • Van Hau Le
    @haulv started a discussion on the diff Feb 17, 2020
    Resolved by Nguyen Ngoc Nghia Feb 18, 2020
    app/services/solr_service.rb 0 → 100644
    32 @solr.delete_by_query("*:*")
    33 @solr.commit
    34 end
    35
    36 def search(params)
    37 # city = @city.present? ? "city:\"#{escape_str(@city.name)}\"" : ""
    38 # industry = @industry.present? ? "industry:\"#{escape_str(@industry.name)}\"" : ""
    39 response = @solr.get "select", params: {
    40 q: "*#{params}*",
    41 # fq: [industry, city],
    42 rows: Job.count
    43 }
    44 response["response"]
    45 end
    46
    47 def escape_str(str)
    • Van Hau Le @haulv commented Feb 17, 2020
      Master

      @nghiann a ko thấy chỗ nào xài cái này! Dư hả em?

      Edited Feb 18, 2020
      @nghiann a ko thấy chỗ nào xài cái này! Dư hả em?
    Please register or sign in to reply
  • Van Hau Le
    @haulv started a discussion on the diff Feb 17, 2020
    Resolved by Nguyen Ngoc Nghia Feb 18, 2020
    app/services/solr_service.rb 0 → 100644
    1 require "rsolr"
    2
    3 class SolrService
    4 def initialize
    5 @solr = RSolr.connect(
    6 url: Settings.solr.connection.server_url,
    7 read_timeout: Settings.solr.connection.read_timeout,
    8 open_timeout: Settings.solr.connection.open_timeout,
    9 retry_503: Settings.solr.connection.retry_503
    10 )
    11 end
    12
    13 def add_data
    14 jobs = Job.includes(:cities, :industries, :company).all
    • Van Hau Le @haulv commented Feb 17, 2020
      Master

      @nghiann này nên catch exception cho nó nhé!

      Edited Feb 18, 2020
      @nghiann này nên catch exception cho nó nhé!
    Please register or sign in to reply
  • Van Hau Le
    @haulv started a discussion on the diff Feb 17, 2020
    Resolved by Nguyen Ngoc Nghia Feb 18, 2020
    app/services/solr_service.rb 0 → 100644
    1 require "rsolr"
    2
    3 class SolrService
    4 def initialize
    5 @solr = RSolr.connect(
    6 url: Settings.solr.connection.server_url,
    7 read_timeout: Settings.solr.connection.read_timeout,
    8 open_timeout: Settings.solr.connection.open_timeout,
    9 retry_503: Settings.solr.connection.retry_503
    10 )
    11 end
    12
    13 def add_data
    14 jobs = Job.includes(:cities, :industries, :company).all
    15 jobs_solr_index = jobs.map do |job|
    • Van Hau Le @haulv commented Feb 17, 2020
      Master

      @nghiann chỗ này xem xét tách ra add mỗi 2 - 5k, không nên add all như vậy!

      Edited Feb 18, 2020
      @nghiann chỗ này xem xét tách ra add mỗi 2 - 5k, không nên add all như vậy!
    Please register or sign in to reply
  • Van Hau Le
    @haulv started a discussion on an old version of the diff Feb 17, 2020
    Automatically resolved by Nguyen Ngoc Nghia with a push Feb 18, 2020
    app/views/jobs/index.html.erb
    1 <%= form_tag( jobs_path, method: :get, class: "form-inline") do %>
    2 <%= search_field_tag :search, params[:search], class: "form-control mb-2 mr-sm-2" %>
    3 <%= submit_tag "Search", class: "btn btn-primary mb-2" %>
    4 <% end %>
    5
    1 6 <h3>Total: <%= params[:city_id] ? @city.job_count :
    2 (params[:industry_id] ? @industry.job_count : Job.count) %></h3>
    3 <h3>Result for: </h3>
    7 (params[:industry_id] ? @industry.job_count : @jobs_count) %></h3>
    • Van Hau Le @haulv commented Feb 17, 2020
      Master

      @nghiann gom vào check 1 lần rồi get result show thôi!

      @nghiann gom vào check 1 lần rồi get result show thôi!
    • Nguyen Ngoc Nghia @nghiann

      changed this line in version 2 of the diff

      Feb 18, 2020

      changed this line in version 2 of the diff

      changed this line in [version 2 of the diff](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/20/diffs?diff_id=4692&start_sha=b7e99753167760f62e25a0300371627e0bbe92f2#fd4909543e4d41ae0af907baf233a50d8e08d125_7_6)
      Toggle commit list
    Please register or sign in to reply
  • Van Hau Le
    @haulv started a discussion on an old version of the diff Feb 17, 2020
    Automatically resolved by Nguyen Ngoc Nghia with a push Feb 18, 2020
    lib/tasks/task.rake
    10
    11 namespace :solr do
    12 desc "solr index data"
    13 task solr_index: :environment do
    14 SolrService.new.add_data
    15
    16 index = ActiveSupport::Logger.new("log/solr_service.log")
    17 index.info "Solr index data succesfully at #{Time.current}"
    18 end
    19
    20 desc "solr delete data"
    21 task solr_delete: :environment do
    22 SolrService.new.delete_data
    23
    24 delete = ActiveSupport::Logger.new("log/solr_service.log")
    25 delete.info "Solr delete all data succesfully at #{Time.current}"
    • Van Hau Le @haulv commented Feb 17, 2020
      Master

      @nghiann đổi cái tên lại nhé! solr_logger hay gì có liên quan 1 chút! Tương tự như ở trên

      Edited Feb 17, 2020 by Van Hau Le
      @nghiann đổi cái tên lại nhé! solr_logger hay gì có liên quan 1 chút! Tương tự như ở trên
    • Nguyen Ngoc Nghia @nghiann

      changed this line in version 2 of the diff

      Feb 18, 2020

      changed this line in version 2 of the diff

      changed this line in [version 2 of the diff](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/20/diffs?diff_id=4692&start_sha=b7e99753167760f62e25a0300371627e0bbe92f2#8bdc06fb3570cc496d75ff451b8ff0608e99ac12_25_24)
      Toggle commit list
    Please register or sign in to reply
  • Nguyen Ngoc Nghia @nghiann

    added 1 commit

    • 5e2c95f2 - query by city/industry

    Compare with previous version

    Feb 18, 2020

    added 1 commit

    • 5e2c95f2 - query by city/industry

    Compare with previous version

    added 1 commit * 5e2c95f2 - query by city&#x2F;industry [Compare with previous version](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/20/diffs?diff_id=4692&start_sha=b7e99753167760f62e25a0300371627e0bbe92f2)
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    changed the description

    Feb 18, 2020

    changed the description

    changed the description
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    resolved all discussions

    Feb 18, 2020

    resolved all discussions

    resolved all discussions
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    resolved all discussions

    Feb 18, 2020

    resolved all discussions

    resolved all discussions
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    added 1 commit

    • 9bcaa5bd - handle exception solr add

    Compare with previous version

    Feb 18, 2020

    added 1 commit

    • 9bcaa5bd - handle exception solr add

    Compare with previous version

    added 1 commit * 9bcaa5bd - handle exception solr add [Compare with previous version](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/20/diffs?diff_id=4693&start_sha=5e2c95f2a3ba1a8030e6749ead62d116260576e1)
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    resolved all discussions

    Feb 18, 2020

    resolved all discussions

    resolved all discussions
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    added 1 commit

    • 5cb0d3a0 - query by city/industry

    Compare with previous version

    Feb 18, 2020

    added 1 commit

    • 5cb0d3a0 - query by city/industry

    Compare with previous version

    added 1 commit * 5cb0d3a0 - query by city&#x2F;industry [Compare with previous version](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/20/diffs?diff_id=4694&start_sha=9bcaa5bd28c4d28d0c4a0ac11eef4f81943f5bfd)
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    resolved all discussions

    Feb 18, 2020

    resolved all discussions

    resolved all discussions
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    added 1 commit

    • cb872093 - fix indent

    Compare with previous version

    Feb 18, 2020

    added 1 commit

    • cb872093 - fix indent

    Compare with previous version

    added 1 commit * cb872093 - fix indent [Compare with previous version](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/20/diffs?diff_id=4695&start_sha=5cb0d3a0fa4a446735a689c332078b943f540dba)
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    resolved all discussions

    Feb 18, 2020

    resolved all discussions

    resolved all discussions
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    added 1 commit

    • 3550ad23 - refactoring queries code

    Compare with previous version

    Feb 18, 2020

    added 1 commit

    • 3550ad23 - refactoring queries code

    Compare with previous version

    added 1 commit * 3550ad23 - refactoring queries code [Compare with previous version](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/20/diffs?diff_id=4699&start_sha=cb872093302505b926f95a009dedf86b1ed5950c)
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    resolved all discussions

    Feb 18, 2020

    resolved all discussions

    resolved all discussions
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    added 1 commit

    • da6e89c7 - refactoring code

    Compare with previous version

    Feb 18, 2020

    added 1 commit

    • da6e89c7 - refactoring code

    Compare with previous version

    added 1 commit * da6e89c7 - refactoring code [Compare with previous version](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/20/diffs?diff_id=4700&start_sha=3550ad230aa4d543f7a31472fd13374ebb5ee2f9)
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    resolved all discussions

    Feb 18, 2020

    resolved all discussions

    resolved all discussions
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    added 1 commit

    • 220a6675 - removing some code

    Compare with previous version

    Feb 18, 2020

    added 1 commit

    • 220a6675 - removing some code

    Compare with previous version

    added 1 commit * 220a6675 - removing some code [Compare with previous version](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/20/diffs?diff_id=4702&start_sha=da6e89c75a0d3ce2938936ea297ce7589b08837a)
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    resolved all discussions

    Feb 18, 2020

    resolved all discussions

    resolved all discussions
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    added 1 commit

    • a9f7ae86 - fix indent

    Compare with previous version

    Feb 18, 2020

    added 1 commit

    • a9f7ae86 - fix indent

    Compare with previous version

    added 1 commit * a9f7ae86 - fix indent [Compare with previous version](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/20/diffs?diff_id=4703&start_sha=220a6675b9558728906632a13c97868e08f20b48)
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    changed the description

    Feb 20, 2020

    changed the description

    changed the description
    Toggle commit list
  • Van Hau Le
    @haulv started a discussion on an old version of the diff Feb 20, 2020
    Automatically resolved by Nguyen Ngoc Nghia with a push Feb 20, 2020
    app/services/solr_service.rb 0 → 100644
    54
    55 send_request(q, fq)
    56 end
    57
    58 def query_by_city
    59 city = City.find(@search_keyword)
    60 city_name = city.name
    61
    62 q = "*:*"
    63 fq = "city: #{escape_str(city_name)}"
    64
    65 send_request(q, fq)
    66 end
    67
    68 def query_by_industry
    69 industry = Industry.find(@search_keyword)
    • Van Hau Le @haulv commented Feb 20, 2020
      Master

      @nghiann return [] unless industry the same for city

      @nghiann return [] unless industry the same for city
    • Nguyen Ngoc Nghia @nghiann

      changed this line in version 10 of the diff

      Feb 20, 2020

      changed this line in version 10 of the diff

      changed this line in [version 10 of the diff](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/20/diffs?diff_id=4706&start_sha=a9f7ae86c1a7406e0cb196ccb6108135c1395603#84ba0610549da3137f298fd4e2a69b15774a178a_69_69)
      Toggle commit list
    Please register or sign in to reply
  • Van Hau Le
    @haulv started a discussion on an old version of the diff Feb 20, 2020
    Automatically resolved by Nguyen Ngoc Nghia with a push Feb 20, 2020
    app/services/solr_service.rb 0 → 100644
    1 require "rsolr"
    2
    3 class SolrService
    4 def initialize(search_keyword)
    • Van Hau Le @haulv commented Feb 20, 2020
      Master

      @nghiann this is argument was passing from outside! So you should set default value. Avoid in case init object without param will be error def initialize(search_keyword = {} )

      @nghiann this is argument was passing from outside! So you should set default value. Avoid in case init object without param will be error `def initialize(search_keyword = {} )`
    • Nguyen Ngoc Nghia @nghiann

      changed this line in version 10 of the diff

      Feb 20, 2020

      changed this line in version 10 of the diff

      changed this line in [version 10 of the diff](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/20/diffs?diff_id=4706&start_sha=a9f7ae86c1a7406e0cb196ccb6108135c1395603#84ba0610549da3137f298fd4e2a69b15774a178a_4_4)
      Toggle commit list
    Please register or sign in to reply
  • Van Hau Le
    @haulv started a discussion on an old version of the diff Feb 20, 2020
    Automatically resolved by Nguyen Ngoc Nghia with a push Feb 20, 2020
    lib/tasks/task.rake
    7 7 import.info "Cities, industries, companies, jobs imported succesfully at #{Time.current}"
    8 8 end
    9 9 end
    10
    11 namespace :solr do
    12 desc "solr index data"
    13 task solr_index: :environment do
    14 SolrService.new.add_data
    15
    16 solr_index_data = ActiveSupport::Logger.new("log/solr_service.log")
    • Van Hau Le @haulv commented Feb 20, 2020
      Master

      @nghiann please change them become to solr_index_logger and solr_delete_logger. They are logger, not data!

      Edited Feb 20, 2020 by Van Hau Le
      @nghiann please change them become to `solr_index_logger` and `solr_delete_logger`. They are logger, not data!
    • Nguyen Ngoc Nghia @nghiann

      changed this line in version 10 of the diff

      Feb 20, 2020

      changed this line in version 10 of the diff

      changed this line in [version 10 of the diff](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/20/diffs?diff_id=4706&start_sha=a9f7ae86c1a7406e0cb196ccb6108135c1395603#8bdc06fb3570cc496d75ff451b8ff0608e99ac12_16_16)
      Toggle commit list
    Please register or sign in to reply
  • Nguyen Ngoc Nghia @nghiann

    resolved all discussions

    Feb 20, 2020

    resolved all discussions

    resolved all discussions
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    added 1 commit

    • 2315b850 - check if city/industry id valid

    Compare with previous version

    Feb 20, 2020

    added 1 commit

    • 2315b850 - check if city/industry id valid

    Compare with previous version

    added 1 commit * 2315b850 - check if city&#x2F;industry id valid [Compare with previous version](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/20/diffs?diff_id=4706&start_sha=a9f7ae86c1a7406e0cb196ccb6108135c1395603)
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    resolved all discussions

    Feb 20, 2020

    resolved all discussions

    resolved all discussions
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    added 1 commit

    • ca3f0a29 - check if city/industry id valid

    Compare with previous version

    Feb 20, 2020

    added 1 commit

    • ca3f0a29 - check if city/industry id valid

    Compare with previous version

    added 1 commit * ca3f0a29 - check if city&#x2F;industry id valid [Compare with previous version](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/20/diffs?diff_id=4707&start_sha=2315b850ec1d8b002be71641d58f28c515198366)
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    resolved all discussions

    Feb 20, 2020

    resolved all discussions

    resolved all discussions
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    added 1 commit

    • 5e442bda - change params pass into @search

    Compare with previous version

    Feb 20, 2020

    added 1 commit

    • 5e442bda - change params pass into @search

    Compare with previous version

    added 1 commit * 5e442bda - change params pass into @search [Compare with previous version](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/20/diffs?diff_id=4708&start_sha=ca3f0a295ed83e8fc576c8fb55f1f90aa8033f6d)
    Toggle commit list
  • Van Hau Le @haulv

    mentioned in commit 88267603

    Feb 20, 2020

    mentioned in commit 88267603

    mentioned in commit 882676039a173bbf9401890edd976c46bd674ab9
    Toggle commit list
  • Van Hau Le @haulv

    merged

    Feb 20, 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
Nguyen Ngoc Nghia
Assignee
Nguyen Ngoc Nghia @nghiann
Assign to
None
Milestone
None
Assign milestone
Time tracking
2
2 participants
Reference: nghiann/VeNJOB!20
×

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.