From 064ab4fa280d3dc79bc9671891e46b5b72e06fac Mon Sep 17 00:00:00 2001 From: Benjamin ter Kuile Date: Sat, 25 Aug 2018 11:37:29 -0500 Subject: [PATCH] Add comments --- app/helpers/dunlop/authorization_helper.rb | 2 ++ app/models/dunlop/source_file_model.rb | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/helpers/dunlop/authorization_helper.rb b/app/helpers/dunlop/authorization_helper.rb index a817130..c36cd66 100644 --- a/app/helpers/dunlop/authorization_helper.rb +++ b/app/helpers/dunlop/authorization_helper.rb @@ -3,6 +3,8 @@ module Dunlop::AuthorizationHelper Dunlop::Ability.has_permission_of_type(type, user) end + # - if any_permission_starts_with 'source-file' + # NOTE: always true for admin users def any_permission_starts_with(expression, user = current_user) Dunlop::Ability.any_permission_starts_with(expression, user) end diff --git a/app/models/dunlop/source_file_model.rb b/app/models/dunlop/source_file_model.rb index 5420300..f608071 100644 --- a/app/models/dunlop/source_file_model.rb +++ b/app/models/dunlop/source_file_model.rb @@ -34,8 +34,12 @@ module Dunlop::SourceFileModel event(:failed) { transition any => :failed } end - after_commit(on: :create) { autoload! } + after_commit(on: :create) { autoload! } # always autoload!, is empty method, can be implemented + # Auto generate the SourceFile::Job that allows processing by worker. For example + # def autoload + # SourceFile::Job.perform_later(id) + # end self::Job = Class.new "#{name.deconstantize}::ApplicationJob".constantize do def perform(source_file_id) return unless source_file = self.class.name.sub(/::Job$/, '').constantize.find(source_file_id) @@ -45,6 +49,8 @@ module Dunlop::SourceFileModel end end + # NOTE:/TODO: this strategy is incompatible with handling multiple files of the same type at the same time. Should be completely substituted by + # a sequential (elastic beanstalk is not sequential when worker has more than 1 thread) queue based worder implementation def deactivate_loaded_source_file self.class.active.update_all state: 'inactive' end