Skip to content

Commit

Permalink
add professional area to skills
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiomagalhaes committed Dec 10, 2024
1 parent e30782f commit 388b646
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 16 deletions.
1 change: 1 addition & 0 deletions app/controllers/analytics/skills_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def build_report
@skills.map do |skill|
{
name: skill.name,
professional_area: skill.professional_area,
level: UserSkill::VALID_LEVELS.map do |level|
{
name: level,
Expand Down
5 changes: 4 additions & 1 deletion app/controllers/requirements_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ def index
statement_of_works_ids = project.statement_of_works.map(&:id)
elsif requirements_filter[:statement_of_work_id].present?
statement_of_works_ids = [requirements_filter[:statement_of_work_id]]
elsif requirements_filter[:assignments_ids].present?
assignments = Assignment.where(id: requirements_filter[:assignments_ids])
statement_of_works_ids = assignments.map(&:statement_of_work_id).uniq
else
render json: { error: 'project_id or statement_of_work_id is required' }, status: :bad_request
return
Expand Down Expand Up @@ -54,6 +57,6 @@ def requirement_params
end

def requirements_filter
params.permit(:project_id, :statement_of_work_id, :start_date, :end_date)
params.permit(:project_id, :statement_of_work_id, :start_date, :end_date, :assignments_ids)
end
end
2 changes: 1 addition & 1 deletion app/controllers/skills_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ def create

# Only allow a trusted parameter "white list" through.
def skill_params
params.require(:skill).permit(:name)
params.require(:skill).permit(:name, :professional_area)
end
end
10 changes: 6 additions & 4 deletions app/models/skill.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
#
# Table name: skills
#
# id :bigint not null, primary key
# name :string
# created_at :datetime not null
# updated_at :datetime not null
# id :bigint not null, primary key
# name :string
# professional_area :string
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
Expand All @@ -18,4 +19,5 @@ class Skill < ApplicationRecord
has_many :users, through: :user_skills

validates :name, presence: true, uniqueness: { case_sensitive: false }
validates :professional_area, presence: true, inclusion: { in: %w[design engineering] }
end
2 changes: 1 addition & 1 deletion app/views/skills/_skill.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# frozen_string_literal: true

json.extract! skill, :id, :name
json.extract! skill, :id, :name, :professional_area
2 changes: 2 additions & 0 deletions app/views/users/_user.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ json.user_service_identifiers user.user_service_identifiers,
partial: 'user_service_identifiers/user_service_identifier', as: :user_service_identifier

json.user_skills user.user_skills, partial: 'user_skills/user_skill', as: :user_skill

json.assignments user.assignments, partial: 'assignments/assignment', as: :assignment
7 changes: 7 additions & 0 deletions db/migrate/20241210175942_add_professional_area_to_skill.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

class AddProfessionalAreaToSkill < ActiveRecord::Migration[7.0]
def change
add_column :skills, :professional_area, :string
end
end
4 changes: 3 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions spec/factories/skills.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
#
# Table name: skills
#
# id :bigint not null, primary key
# name :string
# created_at :datetime not null
# updated_at :datetime not null
# id :bigint not null, primary key
# name :string
# professional_area :string
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
Expand Down
9 changes: 5 additions & 4 deletions spec/models/skill_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
#
# Table name: skills
#
# id :bigint not null, primary key
# name :string
# created_at :datetime not null
# updated_at :datetime not null
# id :bigint not null, primary key
# name :string
# professional_area :string
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
Expand Down

0 comments on commit 388b646

Please sign in to comment.