aboutsummaryrefslogtreecommitdiffstats
path: root/app/services
diff options
context:
space:
mode:
authorcedricnjanga2018-02-14 06:26:04 -0800
committerGitHub2018-02-14 06:26:04 -0800
commit3916476c64dc690195a1273dab7188bb48f69152 (patch)
tree4b0c02015b4e41ffb8bad34d3694266eae25ca20 /app/services
parent2b37ca3b2f57d4c8cb00e18ce39371e7aefc1db3 (diff)
parent385a9e1b68f3eea51f71386a8f4856477ba6a273 (diff)
downloadchouette-core-3562_ccset_affectation.tar.bz2
Merge branch 'master' into 3562_ccset_affectation3562_ccset_affectation
Diffstat (limited to 'app/services')
-rw-r--r--app/services/parent_import_notifier.rb15
-rw-r--r--app/services/parent_notifier.rb19
2 files changed, 19 insertions, 15 deletions
diff --git a/app/services/parent_import_notifier.rb b/app/services/parent_import_notifier.rb
deleted file mode 100644
index 47e6755e4..000000000
--- a/app/services/parent_import_notifier.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-class ParentImportNotifier
- def self.notify_when_finished(imports = nil)
- imports ||= imports_pending_notification
- imports.each(&:notify_parent)
- end
-
- def self.imports_pending_notification
- Import
- .where(
- notified_parent_at: nil,
- status: Import.finished_statuses
- )
- .where.not(parent: nil)
- end
-end
diff --git a/app/services/parent_notifier.rb b/app/services/parent_notifier.rb
new file mode 100644
index 000000000..653c98aff
--- /dev/null
+++ b/app/services/parent_notifier.rb
@@ -0,0 +1,19 @@
+class ParentNotifier
+ def initialize(klass)
+ @klass = klass
+ end
+
+ def notify_when_finished(collection = nil)
+ collection ||= objects_pending_notification
+ collection.each(&:notify_parent)
+ end
+
+ def objects_pending_notification
+ @klass
+ .where(
+ notified_parent_at: nil,
+ status: @klass.finished_statuses
+ )
+ .where.not(parent: nil)
+ end
+end