next_sgad 0.3.2 → 0.3.3
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/assessment.rb +1 -1
- data/app/models/next_sgad/department.rb +1 -0
- data/app/models/next_sgad/employee.rb +29 -0
- data/app/models/next_sgad/goal.rb +2 -2
- data/app/models/next_sgad/position.rb +9 -1
- data/db/migrate/20180106144337_add_can_be_assessed_to_next_sgad_employees.rb +5 -0
- data/lib/next_sgad/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2443dd89ebec47f878c38f414ef401ba42166c1
|
4
|
+
data.tar.gz: 4edd9c740b14e8b7b1806e1b1f6d3acc91910c5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33c7f54f9abde63999a3fd847b94e333a674748af7e79a78b9ceef98fb9cfb7675b44f26754786ec2b1e35dc583a681c604d5a1e6b6fed0d1814102a31ec8099
|
7
|
+
data.tar.gz: 865af0254e701e721e0f93ebce2aba75321348d4b66994933b16749484aea2b818bf4150c7a6a5947c6b92b39846372dc71ddfe35f41bfb8597a5a8f1e9cc193
|
@@ -150,7 +150,7 @@ module NextSgad
|
|
150
150
|
|
151
151
|
def create_employees_assessments
|
152
152
|
begin
|
153
|
-
emplos = NextSgad::Employee.
|
153
|
+
emplos = NextSgad::Employee.can_be_assessed.map{|e| {employee_id: e.id}}
|
154
154
|
# Creates an array like [{employee_id: 1}, {employee_id: 3}]
|
155
155
|
NextSgad::EmployeeAssessment.create(emplos) do |f|
|
156
156
|
f.assessment_id = id
|
@@ -3,6 +3,7 @@ module NextSgad
|
|
3
3
|
# belongs_to :position
|
4
4
|
has_many :employee_goals, dependent: :destroy
|
5
5
|
has_many :employee_messages, dependent: :destroy
|
6
|
+
has_many :attendances, dependent: :destroy
|
6
7
|
has_and_belongs_to_many :positions, association_foreign_key: :next_sgad_position_id, foreign_key: :next_sgad_employee_id
|
7
8
|
has_one :efective_position, class_name: NextSgad::Position.name, foreign_key: :efective_id
|
8
9
|
has_many :employees_assessments, dependent: :destroy
|
@@ -27,8 +28,25 @@ module NextSgad
|
|
27
28
|
employee_messages.unread
|
28
29
|
end
|
29
30
|
|
31
|
+
def self.can_be_assessed
|
32
|
+
where(can_be_assessed: true)
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.cannot_be_assessed
|
36
|
+
where(can_be_assessed: false)
|
37
|
+
end
|
38
|
+
|
39
|
+
def is_assessed?
|
40
|
+
can_be_assessed
|
41
|
+
end
|
42
|
+
|
43
|
+
def is_not_assessed?
|
44
|
+
!is_assessed?
|
45
|
+
end
|
46
|
+
|
30
47
|
INITIAL_LETTER = "E"
|
31
48
|
before_save :create_number, on: :create
|
49
|
+
after_save :remove_assessment_data_if_employee_not_assessed
|
32
50
|
validates_presence_of :first_name, :last_name
|
33
51
|
after_create :create_employees_assessments
|
34
52
|
|
@@ -44,5 +62,16 @@ module NextSgad
|
|
44
62
|
p $!.bactrace
|
45
63
|
end
|
46
64
|
end
|
65
|
+
|
66
|
+
def remove_assessment_data_if_employee_not_assessed
|
67
|
+
if is_not_assessed?
|
68
|
+
active_assessment = NextSgad::Assessment.active.last
|
69
|
+
if active_assessment.present?
|
70
|
+
employee_goals.where(assessment_id: active_assessment.id).delete_all
|
71
|
+
attendances.where("extract(year from date) = ?", active_assessment.year).delete_all
|
72
|
+
employees_assessments.where(assessment_id: active_assessment.id).delete_all
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
47
76
|
end
|
48
77
|
end
|
@@ -33,7 +33,7 @@ module NextSgad
|
|
33
33
|
if skill?
|
34
34
|
# create new
|
35
35
|
positions_to = for_everyone ? NextSgad::Position.all.where.not(efective_id: nil) : NextSgad::Position.where(function_id: function_ids).where.not(efective_id: nil)
|
36
|
-
positions_to.each do |position|
|
36
|
+
positions_to.can_be_assessed.each do |position|
|
37
37
|
next if position.efective_id.nil?
|
38
38
|
eg = NextSgad::EmployeeGoal.new
|
39
39
|
eg.status = status
|
@@ -51,7 +51,7 @@ module NextSgad
|
|
51
51
|
|
52
52
|
elsif objective?
|
53
53
|
positions_to = for_everyone ? NextSgad::Position.all.where.not(efective_id: nil) : positions
|
54
|
-
positions_to.each do |position|
|
54
|
+
positions_to.can_be_assessed.each do |position|
|
55
55
|
next if position.efective_id.nil?
|
56
56
|
eg = NextSgad::EmployeeGoal.new
|
57
57
|
eg.status = status
|
@@ -36,7 +36,7 @@ module NextSgad
|
|
36
36
|
|
37
37
|
def create_goals_after_create
|
38
38
|
assessm = NextSgad::Assessment.active.last
|
39
|
-
return if assessm.nil? || function_id.nil? || efective_id.nil?
|
39
|
+
return if assessm.nil? || function_id.nil? || efective_id.nil? || efective.is_not_assessed?
|
40
40
|
function.goals.where(assessment_id: assessm.id).each do |goal|
|
41
41
|
eg = NextSgad::EmployeeGoal.new
|
42
42
|
eg.status = goal.status
|
@@ -53,5 +53,13 @@ module NextSgad
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
def self.can_be_assessed
|
57
|
+
where(efective_id: [NextSgad::Employee.can_be_assessed.ids, nil])
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.cannot_be_assessed
|
61
|
+
where(efective_id: NextSgad::Employee.cannot_be_assessed.ids)
|
62
|
+
end
|
63
|
+
|
56
64
|
end
|
57
65
|
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.3
|
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-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -260,6 +260,7 @@ files:
|
|
260
260
|
- db/migrate/20180103084324_create_join_table_message_function.rb
|
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
|
+
- db/migrate/20180106144337_add_can_be_assessed_to_next_sgad_employees.rb
|
263
264
|
- lib/concerns/models/employee.rb
|
264
265
|
- lib/generators/initializer/USAGE
|
265
266
|
- lib/generators/initializer/initializer_generator.rb
|