next_sgad 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/next_sgad/application_record.rb +1 -0
- data/app/models/next_sgad/assessment.rb +3 -0
- data/app/models/next_sgad/attendance.rb +11 -0
- data/app/models/next_sgad/employee.rb +6 -0
- data/app/models/next_sgad/employee_assessment.rb +5 -0
- data/app/models/next_sgad/employee_goal.rb +2 -0
- data/app/models/next_sgad/employee_message.rb +1 -0
- data/app/models/next_sgad/goal.rb +3 -0
- data/app/models/next_sgad/message.rb +11 -2
- data/app/models/next_sgad/position.rb +4 -0
- data/db/migrate/20180107204755_create_join_table_message_department.rb +8 -0
- data/db/migrate/20180107204810_create_join_table_message_position.rb +8 -0
- data/db/migrate/20180107204831_create_join_table_message_employee.rb +8 -0
- data/lib/next_sgad/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff5e669903d0b2888d8f1bae8aebcf8b5998edeb
|
4
|
+
data.tar.gz: c3d169d807700d36bc32618920460580419c5922
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9963b87142c0a3b9e4490379510d10045b09397c30a1bc9ee89f02d9d6c1a149396cf8e5b3d3493987ad4bec589afbc021cb62494c381297d45ca1db712874a
|
7
|
+
data.tar.gz: 8892965d4b17c1b40b69ec6dbc9527fd55f9cf93905ce7fbbcf46fc1c255d5ba60b885918308da30f96b693d573b48584f1a382898a4506c53a09d5867dec973
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module NextSgad
|
2
2
|
class ApplicationRecord < ::ApplicationRecord
|
3
3
|
self.abstract_class = true
|
4
|
+
scope :filter, -> (column, data) {data = [data].flatten.compact.uniq; data.blank? || data.include?('all') ? all : where(column => data)}
|
4
5
|
|
5
6
|
def create_number
|
6
7
|
tipo = self.class.name
|
@@ -6,6 +6,9 @@ module NextSgad
|
|
6
6
|
has_many :employees_assessments, dependent: :destroy
|
7
7
|
enum status: {draft: 0, active: 1, inactive: 2, closed: 3}
|
8
8
|
|
9
|
+
scope :year, -> (data) {data = [data].flatten.compact.uniq; data.blank? || data.include?('all') ? all : where(year: data)}
|
10
|
+
scope :status, -> (data) {data = [data].flatten.compact.uniq; data.blank? || data.include?('all') ? all : where(status: data)}
|
11
|
+
|
9
12
|
validates_uniqueness_of :year
|
10
13
|
validates_presence_of :status, :skills_percentage, :year
|
11
14
|
validates :skills_percentage, :objectives_percentage, :attendance_percentage, numericality: {greater_than_or_equal_to: 0, less_than_or_equal_to: 100}
|
@@ -7,6 +7,17 @@ module NextSgad
|
|
7
7
|
has_and_belongs_to_many :justifications, association_foreign_key: :next_sgad_justification_id, foreign_key: :next_sgad_attendance_id
|
8
8
|
enum status: {four_hours_late: -4, three_hours_late: -3, two_hours_late: -2, one_hour_late: -1, presence: 0, absence: 1, vacation: 2, authorized_leave: 3}
|
9
9
|
enum justification_status: {unjustified: -1, pending: 0, approved: 1, disapproved: 2, in_progress: 3}
|
10
|
+
|
11
|
+
scope :department_id, -> (data) {data = [data].flatten.compact.uniq; data.blank? || data.include?('all') ? all : where(department_id: data)}
|
12
|
+
scope :year, -> (data) {data = [data].flatten.compact.uniq; data.blank? || data.include?('all') ? all : where_date(:date, year: data)}
|
13
|
+
scope :from_date, -> (data) {data = [data].flatten.compact.uniq; data.blank? || data.include?('all') ? all : where("date >= ?", data)}
|
14
|
+
scope :to_date, -> (data) {data = [data].flatten.compact.uniq; data.blank? || data.include?('all') ? all : where("date <= ?", data)}
|
15
|
+
#scope :from_to_date, -> (data){nil.present? ? where(date: [data].flatten.compact.uniq.map{|f| f.split(',,,')}.flatten.uniq.split(' - ')[0]..data.split(' - ')[1])}
|
16
|
+
scope :employee_id, -> (data) {data = [data].flatten.compact.uniq; data.blank? || data.include?('all') ? all : where(employee_id: data)}
|
17
|
+
scope :position_id, -> (data) {data = [data].flatten.compact.uniq; data.blank? || data.include?('all') ? all : where(position_id: data)}
|
18
|
+
scope :assessment_id, -> (data) {data = [data].flatten.compact.uniq; data.blank? || data.include?('all') ? all : where(assessment_id: data)}
|
19
|
+
scope :justification_status, -> (data) {data = [data].flatten.compact.uniq; data.blank? || data.include?('all') ? all : where(justification_status: data)}
|
20
|
+
|
10
21
|
validates :status, :date ,:employee_id, presence: true
|
11
22
|
validate :assessment_date
|
12
23
|
before_create :check_employee_data
|
@@ -8,6 +8,12 @@ module NextSgad
|
|
8
8
|
has_one :efective_position, class_name: NextSgad::Position.name, foreign_key: :efective_id
|
9
9
|
has_many :employees_assessments, dependent: :destroy
|
10
10
|
|
11
|
+
scope :department_id, -> (data) {data = [data].flatten.compact.uniq; data.blank? || data.include?('all') ? all : where(id: NextSgad::Position.where(department_id: data).map(&:efective_id))}
|
12
|
+
scope :function_id, -> (data) {data = [data].flatten.compact.uniq; data.blank? || data.include?('all') ? all : where(id: NextSgad::Position.where(function_id: data).map(&:efective_id))}
|
13
|
+
scope :paygrade, -> (data) {data = [data].flatten.compact.uniq; data.blank? || data.include?('all') ? all : where(paygrade: data)}
|
14
|
+
scope :position_id, -> (data) {data = [data].flatten.compact.uniq; data.blank? || data.include?('all') ? all : where(id: NextSgad::Position.where(id: data).map(&:efective_id))}
|
15
|
+
scope :level, -> (data) {data = [data].flatten.compact.uniq; data.blank? || data.include?('all') ? all : where(level: data)}
|
16
|
+
|
11
17
|
def full_name
|
12
18
|
"#{first_name} #{middle_name} #{last_name}"
|
13
19
|
end
|
@@ -5,6 +5,11 @@ module NextSgad
|
|
5
5
|
enum self_assessment_status: {self_pending: 0, self_in_progress: 1, self_completed: 2}
|
6
6
|
enum supervisor_assessment_status: {supervisor_pending: 0, supervisor_in_progress: 1, supervisor_completed: 2}
|
7
7
|
enum final_assessment_status: {final_pending: 0, final_in_progress: 1, final_completed: 2}
|
8
|
+
|
9
|
+
scope :self_assessment_status, -> (data) {data = [data].flatten.compact.uniq; data.blank? || data.include?('all') ? all : where(self_assessment_status: data)}
|
10
|
+
scope :supervisor_assessment_status, -> (data) {data = [data].flatten.compact.uniq; data.blank? || data.include?('all') ? all : where(supervisor_assessment_status: data)}
|
11
|
+
scope :final_assessment_status, -> (data) {data = [data].flatten.compact.uniq; data.blank? || data.include?('all') ? all : where(final_assessment_status: data)}
|
12
|
+
|
8
13
|
attr_accessor :has_assessments, :all_asssessments_incomplete
|
9
14
|
|
10
15
|
|
@@ -10,6 +10,8 @@ module NextSgad
|
|
10
10
|
enum goal_type: NextSgad::Goal.goal_types
|
11
11
|
enum unit: NextSgad::Goal.units
|
12
12
|
enum nature: NextSgad::Goal.natures
|
13
|
+
|
14
|
+
scope :department_id, -> (data) {data = [data].flatten.compact.uniq; data.blank? || data.include?('all') ? all : where(employee_id: NextSgad::Position.where(department_id: data))}
|
13
15
|
|
14
16
|
validates :goal_id, uniqueness: {scope: [:employee_id]}
|
15
17
|
validates :self_assessment, :supervisor_assessment, :final_assessment, numericality: {greater_than_or_equal_to: 0, less_than_or_equal_to: 5}
|
@@ -7,6 +7,7 @@ module NextSgad
|
|
7
7
|
validates_presence_of :employee_id, :message_id
|
8
8
|
validates_uniqueness_of :employee_id, scope: [:message_id]
|
9
9
|
|
10
|
+
# marks a message as read and saves the date the message was read
|
10
11
|
def mark_as_read(curr_employee = nil)
|
11
12
|
return false unless curr_employee.class.name.eql?(NextSgad::Employee.name)
|
12
13
|
return false if read?
|
@@ -10,6 +10,9 @@ module NextSgad
|
|
10
10
|
enum unit: {contracts: 0, currency: 1, clients: 2}
|
11
11
|
enum nature: {numeric: 0, objective_base: 1}
|
12
12
|
|
13
|
+
scope :goal_type, -> (data) {data = [data].flatten.compact.uniq; data.blank? || data.include?('all') ? all : where(goal_type: data)}
|
14
|
+
scope :assessment_id, -> (data) {data = [data].flatten.compact.uniq; data.blank? || data.include?('all') ? all : where(assessment_id: data)}
|
15
|
+
|
13
16
|
validates_presence_of :name, :assessment_id, :status, :nature, :goal_type
|
14
17
|
validates :target, numericality: {greater_than: 0, message: 'Deve ser Maior do que 0'}, if:->(goal){goal.numeric?}
|
15
18
|
#validates :name, uniqueness: {scope: [:assessment_id]}
|
@@ -2,11 +2,17 @@ module NextSgad
|
|
2
2
|
class Message < NextSgad::ApplicationRecord
|
3
3
|
has_many :employee_messages
|
4
4
|
has_and_belongs_to_many :functions, association_foreign_key: :next_sgad_function_id, foreign_key: :next_sgad_message_id
|
5
|
+
has_and_belongs_to_many :positions, association_foreign_key: :next_sgad_position_id, foreign_key: :next_sgad_message_id
|
6
|
+
has_and_belongs_to_many :employees, association_foreign_key: :next_sgad_employee_id, foreign_key: :next_sgad_message_id
|
7
|
+
has_and_belongs_to_many :departments, association_foreign_key: :next_sgad_department_id, foreign_key: :next_sgad_message_id
|
5
8
|
enum status: {draft: 0, sent: 1}
|
6
9
|
|
7
10
|
|
8
11
|
validates_presence_of :title, :body
|
9
|
-
validates_presence_of :functions,
|
12
|
+
validates_presence_of :functions, if: -> (f){!f.send_to_all && f.position_ids.blank? && f.employee_ids.blank? && f.department_ids.blank? && !f.draft?}
|
13
|
+
validates_presence_of :positions, if: -> (f){!f.send_to_all && f.employee_ids.blank? && f.department_ids.blank? && f.function_ids.blank? && !f.draft?}
|
14
|
+
validates_presence_of :departments, if: -> (f){!f.send_to_all && f.position_ids.blank? && f.employee_ids.blank? && f.function_ids.blank? && !f.draft?}
|
15
|
+
validates_presence_of :employees, if: -> (f){!f.send_to_all && f.position_ids.blank? && f.department_ids.blank? && f.function_ids.blank? && !f.draft?}
|
10
16
|
|
11
17
|
after_save :create_messages
|
12
18
|
|
@@ -17,7 +23,10 @@ module NextSgad
|
|
17
23
|
if send_to_all
|
18
24
|
all_employees_ids = NextSgad::Employee.ids
|
19
25
|
else
|
20
|
-
all_employees_ids = NextSgad::Position.where(function_id: functions.ids).map(&:efective_id)
|
26
|
+
all_employees_ids = NextSgad::Position.where(function_id: functions.ids).map(&:efective_id) +
|
27
|
+
NextSgad::Position.where(department_id: departments.ids).map(&:efective_id) +
|
28
|
+
positions.map(&:efective_id) +
|
29
|
+
employees.ids
|
21
30
|
end
|
22
31
|
all_employees_ids.each do |employee_id|
|
23
32
|
duped_empl_message = empl_message.dup
|
@@ -11,6 +11,10 @@ module NextSgad
|
|
11
11
|
has_and_belongs_to_many :goals, association_foreign_key: :next_sgad_goal_id, foreign_key: :next_sgad_position_id
|
12
12
|
has_and_belongs_to_many :employees, association_foreign_key: :next_sgad_employee_id, foreign_key: :next_sgad_position_id
|
13
13
|
|
14
|
+
scope :department_id, -> (data) {data = [data].flatten.compact.uniq; data.blank? || data.include?('all') ? all : where(department_id: data)}
|
15
|
+
scope :efective_id, -> (data) {data = [data].flatten.compact.uniq; data.blank? || data.include?('all') ? all : where(efective_id: data)}
|
16
|
+
scope :position_id, -> (data) {data = [data].flatten.compact.uniq; data.blank? || data.include?('all') ? all : where(position_id: data)}
|
17
|
+
|
14
18
|
def self.ocupied
|
15
19
|
self.where.not(efective_id: nil)
|
16
20
|
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
class CreateJoinTableMessageDepartment < ActiveRecord::Migration[5.1]
|
2
|
+
def change
|
3
|
+
create_join_table :next_sgad_messages, :next_sgad_departments do |t|
|
4
|
+
t.index [:next_sgad_message_id, :next_sgad_department_id], name: 'idx_nt_sd_depents_meges_on_sgad_message_id_and_sgad_depent_id'
|
5
|
+
# t.index [:department_id, :message_id]
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
class CreateJoinTableMessagePosition < ActiveRecord::Migration[5.1]
|
2
|
+
def change
|
3
|
+
create_join_table :next_sgad_messages, :next_sgad_positions do |t|
|
4
|
+
t.index [:next_sgad_message_id, :next_sgad_position_id], name: 'index_sgad_mees_poions_on_sgad_mege_id_and_sgad_poion_id'
|
5
|
+
# t.index [:position_id, :message_id]
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
class CreateJoinTableMessageEmployee < ActiveRecord::Migration[5.1]
|
2
|
+
def change
|
3
|
+
create_join_table :next_sgad_messages, :next_sgad_employees do |t|
|
4
|
+
t.index [:next_sgad_message_id, :next_sgad_employee_id], name: 'index_sgad_eoyees_messages_on_sgad_mage_id_and_sgad_eoyee_id'
|
5
|
+
# t.index [:employee_id, :message_id]
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
data/lib/next_sgad/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: next_sgad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Maziano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -261,6 +261,9 @@ files:
|
|
261
261
|
- db/migrate/20180103085525_create_next_sgad_employee_messages.rb
|
262
262
|
- db/migrate/20180103123801_add_read_date_to_next_sgad_employee_messages.rb
|
263
263
|
- db/migrate/20180106144337_add_can_be_assessed_to_next_sgad_employees.rb
|
264
|
+
- db/migrate/20180107204755_create_join_table_message_department.rb
|
265
|
+
- db/migrate/20180107204810_create_join_table_message_position.rb
|
266
|
+
- db/migrate/20180107204831_create_join_table_message_employee.rb
|
264
267
|
- lib/concerns/models/employee.rb
|
265
268
|
- lib/generators/initializer/USAGE
|
266
269
|
- lib/generators/initializer/initializer_generator.rb
|