Skip to content

Commit

Permalink
add filter by skill first_name last_name email resume_name (Hexlet#413)
Browse files Browse the repository at this point in the history
* add filter by skill first_name last_name email resume_name
  • Loading branch information
usernaimandrey authored and amd-9 committed Jan 17, 2023
1 parent fce8e3d commit ff40c9e
Show file tree
Hide file tree
Showing 16 changed files with 52 additions and 11 deletions.
5 changes: 3 additions & 2 deletions app/controllers/web/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

class Web::HomeController < Web::ApplicationController
def index
q = Resume.web.ransack(params[:q])
@resumes = q.result(distinct: true).page(params[:page])
@q = Resume.web.ransack(params[:q])
@resumes = @q.result(distinct: true).includes(:user).page(params[:page])
@page = params[:page]
@tags = Resume.directions_tags

set_meta_tags og: {
description: t('.description'),
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/web/vacancies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def index
q = Vacancy.web.ransack(params[:q])
@vacancies = q.result(distinct: true).page(params[:page])
@vacancy_search_form = Web::Vacancies::SearchForm.new
@tags = Vacancy.tags_sorted_list
@tags = Vacancy.directions_tags
@page = params[:page]

respond_to do |format|
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/web/vacancy_filters_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def show
@description = t(".options.#{main_key}.#{level_key}.description", default: :"#{default_prefix}.description", **options_for_header)

@vacancy_search_form = Web::Vacancies::SearchForm.new(prepare_options_for_search_form(@options))
@tags = Vacancy.tags_sorted_list
@tags = Vacancy.directions_tags
@vacancies = scope.distinct
@page = params[:page]
end
Expand Down
2 changes: 1 addition & 1 deletion app/forms/web/account/resume_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class Web::Account::ResumeForm < Resume
include ActiveFormModel

attrs = %i[name hexlet_url github_url contact summary skills_description awards_description english_fluency city relocation]
attrs = %i[name hexlet_url github_url contact summary skills_description awards_description english_fluency city relocation skill_list direction_list]
nested_attrs = {
educations_attributes: %i[description begin_date end_date current _destroy id],
works_attributes: %i[company position description begin_date end_date current _destroy id]
Expand Down
3 changes: 3 additions & 0 deletions app/models/resume.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
class Resume < ApplicationRecord
include StateConcern
extend Enumerize
extend TagResumePresenter

has_paper_trail
is_impressionable counter_cache: true

acts_as_taggable_on :skills, :directions

enumerize :english_fluency, in: %i[dont_know basic read pass_interview fluent]
enumerize :locale, in: %i[en ru], default: :ru
enumerize :relocation, in: %i[not_specified another_country another_city another_city_country not_ready], default: :not_specified
Expand Down
2 changes: 1 addition & 1 deletion app/models/vacancy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class Vacancy < ApplicationRecord
include StateConcern
extend Enumerize
extend TagPresenter
extend TagVacancyPresenter
include VacancyRepository
include VacancyPresenter

Expand Down
7 changes: 7 additions & 0 deletions app/presenters/tag_resume_presenter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

module TagResumePresenter
def directions_tags(sort_method = 'ASC')
Resume.tags_on(:directions).order("lower(name) #{sort_method}").pluck(:name)
end
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module TagPresenter
def tags_sorted_list(sort_method = 'ASC')
module TagVacancyPresenter
def directions_tags(sort_method = 'ASC')
Vacancy.tags_on(:directions).order("lower(name) #{sort_method}").pluck(:name)
end
end
8 changes: 7 additions & 1 deletion app/views/web/home/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
- content_for :header do
= t('.header')

.nav.nav-pills.mb-3.justify-content-center
= render partial: 'web/shared/resume_filter', locals: { query: @q, tags: @tags }

.p-3.nav.nav-pills.mb-3.justify-content-center
= filter_link(t('.all'), {}, class: 'nav-item nav-link')
= filter_link(t('.popular'), { created_at_gteq: Date.current - 1.week, popular_gteq: Date.current - 1.week, s: 'impressions_count desc' }, class: 'nav-item nav-link')
= filter_link(t('.newest'), { created_at_gteq: Date.current - 1.day, s: 'created_at desc' }, class: 'nav-item nav-link')
Expand All @@ -31,6 +33,10 @@
h5.card-title.text-break = link_to resume, resume_path(resume)
.card-text.text-break.mb-2 = truncate_markdown(resume.summary, length: 200)
.text-end.small.mt-auto
.d-flex.fw-bold
- resume.skill_list.each do |skill|
.m-1
= filter_link(skill, { skills_name_in: skill }, class: 'nav-item nav-link')
span.me-3.text-muted
= distance_of_time_in_words_to_now resume.created_at
= link_to resume.user, user_path(resume.user)
Expand Down
8 changes: 8 additions & 0 deletions app/views/web/shared/_resume_filter.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.p-3.mb-3.bg-light.rounded-3
= search_form_for query, url: root_path, html: { novalidate: true, class: 'row row-cols-1 row-cols-sm-2 row-cols-lg-3 row-cols-xl-4 g-2 g-lg-3' } do |f|
= f.input :name_cont, label: false, placeholder: t('.name')
= f.input :user_first_name_or_user_last_name_or_user_email_cont, label: false, placeholder: t('.user')
= f.input :directions_name_cont, id: '1', collection: tags, label: false, prompt: t('.directions')
.col.d-flex
= f.button :submit, t('search'), class: 'btn-primary me-2 flex-grow-1'
= link_to t('reset'), url_for, class: 'btn btn-outline-secondary'
4 changes: 4 additions & 0 deletions app/views/web/shared/_resume_form.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
= f.input :skills_description, input_html: { rows: 5 }
.mb-3
= f.input :awards_description, input_html: { rows: 5 }
.mb-3
= f.input :skill_list, input_html: { value: f.object.skill_list.to_s }
.mb-3
= f.input :direction_list, input_html: { value: f.object.direction_list.to_s }
.mb-3
h3 = t('.work')
#works
Expand Down
2 changes: 2 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

require_relative 'boot'

ENV['RANSACK_FORM_BUILDER'] = '::SimpleForm::FormBuilder'

require 'active_model/railtie'
require 'active_job/railtie'
require 'active_record/railtie'
Expand Down
2 changes: 2 additions & 0 deletions config/locales/ru.activerecord.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ ru:
state/draft: Черновик
state/published: Опубликовано
state/archived: В архиве
skill_list: Тэги навыков
direction_list: Направление
resume/answer:
content: Ответ
applying_state/pending: Ожидает подтверждения
Expand Down
4 changes: 2 additions & 2 deletions config/locales/ru.ransack.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ru:
ransack:
# attributes:
# resume:
# name: Имя
# resume:
# name: Имя
4 changes: 4 additions & 0 deletions config/locales/ru.views.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ ru:
header: Упс, а тут пусто
explanation: Такое бывает, когда страницу удалили или в адрес случайно закралась ошибка. Но ничего страшного, можно просто тыкнуть на любой пункт меню сверху и попасть-таки в нужное место.
shared:
resume_filter:
directions: Выберите направление
name: Название резюме
user: Имя/Фамилия/Почта
resume_form:
work: Опыт работы
education: Образование
Expand Down
4 changes: 4 additions & 0 deletions config/locales/simple_form.ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ ru:
В поле используется разметка Markdown (https://guides.hexlet.io/markdown/). Допускается публикация только чистого и форматированного текста (без эмоджи, рекламных вставок и тд)
resume:
city: Укажите город вашего проживания
direction_list: |
Укажите ваше направление. Это поле тегов поможет быстрее находить ваше резюме HR-консультантам и работодателям. Здесь нужно указывать только то, про что можно сказать X-разработчик, например: android, ios, php, js, java и тд
skill_list: |
Укажите ваши навыки. Это поле тегов поможет быстрее находить ваше резюме HR-консультантам и работодателям. Здесь можно указать вашь полный стек, например: ajax, docker, Postgresql и тд.
relocation: Укажите вашу готовность к релокации
hexlet_url: 'Ссылка на профиль: https://ru.hexlet.io/u/mokevnin'
github_url: 'Ссылка на профиль: https://github.com/mokevnin'
Expand Down

0 comments on commit ff40c9e

Please sign in to comment.