From 48726e989bf4eec4bae61e5fbe63a0a45750af5a Mon Sep 17 00:00:00 2001 From: Aday Bujeda Date: Fri, 1 Sep 2023 17:55:49 +0100 Subject: [PATCH] Improvements to script model after review --- apps/dashboard/app/models/script.rb | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/apps/dashboard/app/models/script.rb b/apps/dashboard/app/models/script.rb index 696b889b13..e7cb0e55a7 100644 --- a/apps/dashboard/app/models/script.rb +++ b/apps/dashboard/app/models/script.rb @@ -14,10 +14,6 @@ def scripts_dir(project_dir) end end - def creation_marker_path(script_dir) - File.join(script_dir, ".created.json") - end - def find(id, project_dir) script_path = Script.script_path(project_dir, id) file = script_form_file(script_path) @@ -46,7 +42,7 @@ def from_yaml(file, project_dir) nil end - def next_id(project_dir) + def next_id SecureRandom.alphanumeric(8).downcase end end @@ -131,12 +127,11 @@ def []=(_id, value) end def save - @id = Script.next_id(project_dir) if @id.nil? + @id = Script.next_id if @id.nil? @created_at = Time.now.to_i if @created_at.nil? script_path = Script.script_path(project_dir, id) script_path.mkpath unless script_path.exist? File.write(Script.script_form_file(script_path), to_yaml) - add_creation_marker(script_path) true rescue StandardError => e @@ -256,11 +251,6 @@ def cache_file_exists? cache_file_path.exist? end - def add_creation_marker(script_dir) - creation_marker = Pathname.new(Script.creation_marker_path(script_dir)) - File.write(creation_marker, { }.to_json) unless creation_marker.exist? - end - def cached_values @cached_values ||= begin cache_file_path = OodAppkit.dataroot.join(Script.scripts_dir("#{project_dir}"), "#{id}_opts.json")