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
  • !13

Merged
Opened Dec 13, 2019 by Nguyen Ngoc Nghia@nghiann 
  • Report abuse
Report abuse

Feature/count jobs based on city/industry

  • Have data in city_jobs and industry_jobs table.
  • Count jobs based on city/industry.
  • Show number of jobs based on city on city page and top page.

count_jobs_on_city

Edited Dec 13, 2019 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/count_jobs origin/feature/count_jobs

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/count_jobs

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 15
  • Changes 15
{{ resolvedDiscussionCount }}/{{ discussionCount }} {{ resolvedCountText }} resolved
  • Nguyen Ngoc Nghia @nghiann

    added 1 commit

    • c8d887e1 - delete unused methods

    Compare with previous version

    Dec 13, 2019

    added 1 commit

    • c8d887e1 - delete unused methods

    Compare with previous version

    added 1 commit * c8d887e1 - delete unused methods [Compare with previous version](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/13/diffs?diff_id=4468&start_sha=a7374a6353f4dd2744d95298d8b6f5d660209846)
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    changed title from Feature/count jobs base on city/industry to Feature/count jobs based on city/industry

    Dec 13, 2019

    changed title from Feature/count jobs base on city/industry to Feature/count jobs based on city/industry

    changed title from **Feature/count jobs base on city/industry** to **Feature/count jobs base{+d+} on city/industry**
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    changed the description

    Dec 13, 2019

    changed the description

    changed the description
    Toggle commit list
  • Van Hau Le
    @haulv started a discussion on an old version of the diff Dec 13, 2019
    Automatically resolved by Nguyen Ngoc Nghia with a push Dec 17, 2019
    app/services/jobs_import.rb
    5 5 jobs = []
    6 6 job_columns = [:title, :level, :salary, :description, :short_des,
    7 7 :requirement, :category, :company_id]
    8 city_jobs = []
    9 industry_jobs = []
    8 10
    9 11 CSV.foreach(Rails.root.join("lib", "jobss.csv"), headers: true) do |row|
    10 jobs << JobCsv.new(row).csv_attributes
    12 job_csv = JobCsv.new(row)
    13 jobs << job_csv.csv_attributes
    14 city_jobs << [row["company province"], job_csv.title, job_csv.company_id]
    15 industry_jobs << [row["category"], job_csv.title, job_csv.company_id]
    11 16 end
    12 17
    13 18 Job.import job_columns, jobs
    14 19 puts "Jobs imported"
    • Van Hau Le @haulv commented Dec 13, 2019
      Master

      @nghiann dùng Rails logger, không dùng puts nha em

      https://stackify.com/rails-logger-and-rails-logging-best-practices/

      @nghiann dùng Rails logger, không dùng puts nha em https://stackify.com/rails-logger-and-rails-logging-best-practices/
    • Van Hau Le @haulv commented Dec 13, 2019
      Master

      Tương tự bên dưới

      Tương tự bên dưới
    • Nguyen Ngoc Nghia @nghiann

      changed this line in version 4 of the diff

      Dec 17, 2019

      changed this line in version 4 of the diff

      changed this line in [version 4 of the diff](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/13/diffs?diff_id=4470&start_sha=5726665ab3ae3ebbd046a9d0961d1646800498a5#1f65720902ca3865605cceae7968bb28d7cbe838_17_17)
      Toggle commit list
    Please register or sign in to reply
  • Van Hau Le
    @haulv started a discussion on an old version of the diff Dec 13, 2019
    Automatically resolved by Nguyen Ngoc Nghia with a push Dec 17, 2019
    app/views/cities/_city.html.erb
    1 1 <div class="col-md-3">
    2 2 <div class="col-show">
    3 <%= city.name %>
    3 <%= city.name %> (<%= (city.jobs.count) %>)
    • Van Hau Le @haulv commented Dec 13, 2019
      Master

      @nghiann Nên define job count như 1 method trong ctiy model để cache lại!

      @nghiann Nên define job count như 1 method trong ctiy model để cache lại!
    • Nguyen Ngoc Nghia @nghiann

      changed this line in version 5 of the diff

      Dec 17, 2019

      changed this line in version 5 of the diff

      changed this line in [version 5 of the diff](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/13/diffs?diff_id=4471&start_sha=fb4463166c16fd4c88114dc027355e685a5ec70c#140e9386497ae5ab399fa6c34c5e8d27cd92fd63_3_3)
      Toggle commit list
    Please register or sign in to reply
  • Son Do Hong
    @sondh started a discussion on an old version of the diff Dec 13, 2019
    Automatically resolved by Nguyen Ngoc Nghia with a push Dec 13, 2019
    config/routes.rb
    4 4 resources :cities, only: :index
    5 5 resources :jobs, only: :index
    6 6 devise_for :users
    7 root "static_pages#index"
    8 get "static_pages/index"
    7 root "tops#index"
    8 get "tops/index"
    • Son Do Hong @sondh commented Dec 13, 2019
      Master

      ko cần đến url này

      ko cần đến url này
    • Nguyen Ngoc Nghia @nghiann

      changed this line in version 3 of the diff

      Dec 13, 2019

      changed this line in version 3 of the diff

      changed this line in [version 3 of the diff](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/13/diffs?diff_id=4469&start_sha=c8d887e18e15f6c90ff736862fe808024b57dc45#e801163eb9182955dca3eb9817d59af634f6665d_8_8)
      Toggle commit list
    Please register or sign in to reply
  • Nguyen Ngoc Nghia @nghiann

    added 1 commit

    • 5726665a - edit jobs_import.rb

    Compare with previous version

    Dec 13, 2019

    added 1 commit

    • 5726665a - edit jobs_import.rb

    Compare with previous version

    added 1 commit * 5726665a - edit jobs_import.rb [Compare with previous version](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/13/diffs?diff_id=4469&start_sha=c8d887e18e15f6c90ff736862fe808024b57dc45)
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    added 1 commit

    • fb446316 - using Rails Logger

    Compare with previous version

    Dec 17, 2019

    added 1 commit

    • fb446316 - using Rails Logger

    Compare with previous version

    added 1 commit * fb446316 - using Rails Logger [Compare with previous version](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/13/diffs?diff_id=4470&start_sha=5726665ab3ae3ebbd046a9d0961d1646800498a5)
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    resolved all discussions

    Dec 17, 2019

    resolved all discussions

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

    added 1 commit

    • b0557443 - define method for job count

    Compare with previous version

    Dec 17, 2019

    added 1 commit

    • b0557443 - define method for job count

    Compare with previous version

    added 1 commit * b0557443 - define method for job count [Compare with previous version](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/13/diffs?diff_id=4471&start_sha=fb4463166c16fd4c88114dc027355e685a5ec70c)
    Toggle commit list
  • Van Hau Le
    @haulv started a discussion on an old version of the diff Dec 17, 2019
    Automatically resolved by Nguyen Ngoc Nghia with a push Dec 17, 2019
    app/models/city.rb
    14 14 #
    15 15
    16 16 class City < ApplicationRecord
    17 has_many :city_jobs
    18 has_many :jobs, through: :city_jobs
    19
    17 20 scope :vn_cities, -> {where region: "Việt Nam"}
    18 21 scope :inter_cities, -> {where region: "#"}
    22
    23 def job_count
    24 jobs.count
    • Van Hau Le @haulv commented Dec 17, 2019
      Master

      @nghiann: @job_count ||= jobs.count for cached data!

      @nghiann: `@job_count ||= jobs.count` for cached data!
    • Nguyen Ngoc Nghia @nghiann

      changed this line in version 6 of the diff

      Dec 17, 2019

      changed this line in version 6 of the diff

      changed this line in [version 6 of the diff](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/13/diffs?diff_id=4472&start_sha=b055744337b1dd1a871ab127ec94892eba98736e#28495972e963898abf2919ffeaeb92fbdf49fb8e_24_24)
      Toggle commit list
    Please register or sign in to reply
  • Van Hau Le
    @haulv started a discussion on an old version of the diff Dec 17, 2019
    Automatically resolved by Nguyen Ngoc Nghia with a push Dec 17, 2019
    app/services/jobs_import.rb
    5 5 jobs = []
    6 6 job_columns = [:title, :level, :salary, :description, :short_des,
    7 7 :requirement, :category, :company_id]
    8 join_jobs = []
    8 9
    9 10 CSV.foreach(Rails.root.join("lib", "jobss.csv"), headers: true) do |row|
    10 jobs << JobCsv.new(row).csv_attributes
    11 job_csv = JobCsv.new(row)
    12 jobs << job_csv.csv_attributes
    13 join_jobs << [row["company province"], row["category"], job_csv.title, job_csv.company_id]
    11 14 end
    12 15
    13 16 Job.import job_columns, jobs
    14 puts "Jobs imported"
    17
    18 join_jobs.each do |city_name,industry_name, job_title, company_id|
    • Van Hau Le @haulv commented Dec 17, 2019
      Master

      @nghiann add space sau mỗi comma trong 1ist items nha em!

      @nghiann add space sau mỗi comma trong 1ist items nha em!
    • Nguyen Ngoc Nghia @nghiann

      changed this line in version 6 of the diff

      Dec 17, 2019

      changed this line in version 6 of the diff

      changed this line in [version 6 of the diff](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/13/diffs?diff_id=4472&start_sha=b055744337b1dd1a871ab127ec94892eba98736e#1f65720902ca3865605cceae7968bb28d7cbe838_18_0)
      Toggle commit list
    Please register or sign in to reply
  • Van Hau Le
    @haulv started a discussion on an old version of the diff Dec 17, 2019
    Automatically resolved by Nguyen Ngoc Nghia with a push Dec 17, 2019
    lib/tasks/task.rake
    3 3 task import: :environment do
    4 4 Import.new.import
    5 5 JobsImport.new.import_job
    6
    7 import = ActiveSupport::Logger.new("log/import.log")
    8 import.debug "Cities, industries, companies, jobs imported: #{Time.current}"
    • Van Hau Le @haulv commented Dec 17, 2019
      Master

      @nghiann xài logger level info nha em!

      @nghiann xài logger level info nha em!
    • Nguyen Ngoc Nghia @nghiann

      changed this line in version 6 of the diff

      Dec 17, 2019

      changed this line in version 6 of the diff

      changed this line in [version 6 of the diff](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/13/diffs?diff_id=4472&start_sha=b055744337b1dd1a871ab127ec94892eba98736e#8bdc06fb3570cc496d75ff451b8ff0608e99ac12_8_7)
      Toggle commit list
    Please register or sign in to reply
  • Van Hau Le
    @haulv started a discussion on an old version of the diff Dec 17, 2019
    Automatically resolved by Nguyen Ngoc Nghia with a push Dec 17, 2019
    app/services/jobs_import.rb
    12 jobs << job_csv.csv_attributes
    13 join_jobs << [row["company province"], row["category"], job_csv.title, job_csv.company_id]
    11 14 end
    12 15
    13 16 Job.import job_columns, jobs
    14 puts "Jobs imported"
    17
    18 join_jobs.each do |city_name,industry_name, job_title, company_id|
    19 job = Job.find_by(title: job_title, company_id: company_id)
    20 city = City.find_by(name: city_name)
    21 job.city_jobs.create(city_id: city.id)
    22 industry = Industry.find_by(name: industry_name)
    23 job.industry_jobs.create(industry_id: industry.id)
    24 end
    25
    26 puts "See import.log for more details."
    • Van Hau Le @haulv commented Dec 17, 2019
      Master

      @nghiann sử dùng logger, không dùng puts! Em hiểu sai logger rồi!

      @nghiann sử dùng logger, không dùng puts! Em hiểu sai logger rồi!
    • Nguyen Ngoc Nghia @nghiann

      changed this line in version 6 of the diff

      Dec 17, 2019

      changed this line in version 6 of the diff

      changed this line in [version 6 of the diff](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/13/diffs?diff_id=4472&start_sha=b055744337b1dd1a871ab127ec94892eba98736e#1f65720902ca3865605cceae7968bb28d7cbe838_26_0)
      Toggle commit list
    Please register or sign in to reply
  • Van Hau Le
    @haulv started a discussion on an old version of the diff Dec 17, 2019
    Automatically resolved by Nguyen Ngoc Nghia with a push Dec 17, 2019
    lib/tasks/task.rake
    3 3 task import: :environment do
    4 4 Import.new.import
    5 5 JobsImport.new.import_job
    • Van Hau Le @haulv commented Dec 17, 2019
      Master

      @nghiann refactor lại chỗ này nhé em!

      @nghiann refactor lại chỗ này nhé em!
    • Nguyen Ngoc Nghia @nghiann

      changed this line in version 6 of the diff

      Dec 17, 2019

      changed this line in version 6 of the diff

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

    resolved all discussions

    Dec 17, 2019

    resolved all discussions

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

    added 2 commits

    • 11ade7cf - setting file csv path
    • 55873cff - using rescue

    Compare with previous version

    Dec 17, 2019

    added 2 commits

    • 11ade7cf - setting file csv path
    • 55873cff - using rescue

    Compare with previous version

    added 2 commits * 11ade7cf - setting file csv path * 55873cff - using rescue [Compare with previous version](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/13/diffs?diff_id=4472&start_sha=b055744337b1dd1a871ab127ec94892eba98736e)
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    added 1 commit

    • 3aa0194a - fix indent

    Compare with previous version

    Dec 17, 2019

    added 1 commit

    • 3aa0194a - fix indent

    Compare with previous version

    added 1 commit * 3aa0194a - fix indent [Compare with previous version](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/13/diffs?diff_id=4477&start_sha=55873cff1788b5ad77313b40cad93e49e3fb51d5)
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    added 1 commit

    • 34e7d4fe - order city on top page

    Compare with previous version

    Dec 17, 2019

    added 1 commit

    • 34e7d4fe - order city on top page

    Compare with previous version

    added 1 commit * 34e7d4fe - order city on top page [Compare with previous version](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/13/diffs?diff_id=4482&start_sha=3aa0194a3d4a9c473fffad414f7742d67b6514b7)
    Toggle commit list
  • Nguyen Ngoc Nghia @nghiann

    added 1 commit

    • b565e7d0 - add button for all cities

    Compare with previous version

    Dec 17, 2019

    added 1 commit

    • b565e7d0 - add button for all cities

    Compare with previous version

    added 1 commit * b565e7d0 - add button for all cities [Compare with previous version](https://gitlab.zigexn.vn/nghiann/VeNJOB/merge_requests/13/diffs?diff_id=4483&start_sha=34e7d4fe5098571a32512a3379739b292f0c0d09)
    Toggle commit list
  • Son Do Hong @sondh

    mentioned in commit 31dc3481

    Dec 17, 2019

    mentioned in commit 31dc3481

    mentioned in commit 31dc348148c6d87a30b1a3e43b18db5fab1b9948
    Toggle commit list
  • Son Do Hong @sondh

    merged

    Dec 17, 2019

    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
3
3 participants
Reference: nghiann/VeNJOB!13
×

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.