effective_cpd 1.6.0 → 1.6.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df0aa3e273f4a7e43776b241ff56606c511c4787b6c3377099ac9667d893d56a
4
- data.tar.gz: 1ddbb75a7c986e35a1aa753a7ce8263a6cb2e5751b75c89b3bc6aa1a53a61e68
3
+ metadata.gz: 89acef6977a76e2072c93505be5f2e140df846d7a4c811cf9c6ae6f71b8f7cf5
4
+ data.tar.gz: a3bd58305e0e7ae3667ce9039944dbeba4f4c7a4f4299e48caaf723debc97db3
5
5
  SHA512:
6
- metadata.gz: 84ad353239bfccbc5b3f406b1c1abf9544ce0b4e0a674f953e7dbe1b1befad3131ed05ab198412e9963a074fa21558f1f94d673026e7192d1c2e4ec9a69e6ab4
7
- data.tar.gz: 569f1f59c576c1170c94247a78803a217029234ebcb2ada6fa40f5ebb10671d664b1bfa73732c018d5170520b21eb792e58caebb07515b8584d48aac760c4db3
6
+ metadata.gz: da56f6fa2fe0699f60f071abf0b694621398efaa71979d8d9efdc07974010497d95d20529222609446b0a79f02aebd0527af3b321706a787471e439f98c06693
7
+ data.tar.gz: 297d83fdad2dbf217a16148fd624ce0411db56a937555ec1afb4efa043aeccdcfbb88f0acb713c8f8b46bf98698d21a358d6a9525d4d1c50f88dc5a95ba50c79
@@ -26,8 +26,8 @@ class EffectiveCpdAvailableCyclesDatatable < Effective::Datatable
26
26
 
27
27
  collection do
28
28
  raise('expected a current_user') unless current_user.present?
29
+
29
30
  completed = EffectiveCpd.CpdStatement.completed.where(user: current_user)
30
31
  Effective::CpdCycle.available.where.not(id: completed.select('cpd_cycle_id as id'))
31
32
  end
32
-
33
33
  end
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+ # rubocop:disable all
3
+
1
4
  module Effective
2
5
  class CpdScorer
3
6
  include EffectiveResourcesHelper
@@ -9,9 +12,9 @@ module Effective
9
12
 
10
13
  if from.present?
11
14
  raise('expected from to be a CpdStatement') unless from.class.respond_to?(:effective_cpd_statement?)
15
+
12
16
  @statements = @statements.where('cpd_cycle_id >= ?', from.cpd_cycle_id)
13
17
  end
14
-
15
18
  end
16
19
 
17
20
  def score!
@@ -156,7 +159,11 @@ module Effective
156
159
 
157
160
  def save_carry_forward_activity(existing, statement)
158
161
  activity = statement.cpd_statement_activities.find { |a| a.original == (existing.original || existing) }
159
- activity ||= statement.cpd_statement_activities.build()
162
+
163
+ return if activity.blank? && statement.completed?
164
+ return if activity.blank? && !statement.cpd_cycle.available?
165
+
166
+ activity ||= statement.cpd_statement_activities.build
160
167
 
161
168
  activity.assign_attributes(
162
169
  cpd_category: existing.cpd_category,
@@ -57,8 +57,8 @@ module Effective
57
57
  end
58
58
 
59
59
  validate(if: -> { new_record? && cpd_statement.present? }, unless: -> { importing }) do
60
- self.errors.add(:base, "statement has already been completed") if cpd_statement.completed?
61
- self.errors.add(:base, "cycle is unavailable") unless cpd_statement.cpd_cycle.available?
60
+ errors.add(:base, 'statement has already been completed') if cpd_statement.completed?
61
+ errors.add(:base, 'cycle is unavailable') unless cpd_statement.cpd_cycle.available?
62
62
  end
63
63
 
64
64
  def to_s
@@ -85,6 +85,5 @@ module Effective
85
85
  def to_debug
86
86
  "id=#{id}, score=#{score}, carry_foward=#{carry_forward}, carry_from_last=#{carry_over}, original=#{original&.id}"
87
87
  end
88
-
89
88
  end
90
89
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveCpd
2
- VERSION = '1.6.0'
2
+ VERSION = '1.6.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_cpd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect