Background
CoreFilesController#destroy and ProjectsController#destroy destroy records in Rails but never notify tapas-xq. TEI, MODS, and TFE records accumulate in BaseX indefinitely.
Work required
app/models/core_file.rb
Add after_destroy :enqueue_tapas_xq_deletion and a private method:
def enqueue_tapas_xq_deletion
return unless tapas_xq_doc_id.present?
DeleteFromTapasXqJob.perform_later(
project_id: tapas_xq_project_id,
doc_id: tapas_xq_doc_id
)
end
The tapas_xq_doc_id guard ensures files that were never successfully uploaded (processing failed before completion) don't trigger a pointless deletion attempt. The after_destroy callback runs after the DB row is removed but the in-memory object retains its attribute values, so reading tapas_xq_doc_id here is safe.
app/models/project.rb
Add after_destroy :enqueue_tapas_xq_project_deletion and a private method:
def enqueue_tapas_xq_project_deletion
DeleteProjectFromTapasXqJob.perform_later(id.to_s)
end
Note: id is available on the in-memory object after after_destroy runs.
Dependencies
DeleteFromTapasXqJob and DeleteProjectFromTapasXqJob must exist first
Tests
Add to spec/models/core_file_spec.rb and spec/requests/core_files_spec.rb and spec/requests/projects_spec.rb. See testing plan doc for specific examples.
Background
CoreFilesController#destroyandProjectsController#destroydestroy records in Rails but never notify tapas-xq. TEI, MODS, and TFE records accumulate in BaseX indefinitely.Work required
app/models/core_file.rbAdd
after_destroy :enqueue_tapas_xq_deletionand a private method:The
tapas_xq_doc_idguard ensures files that were never successfully uploaded (processing failed before completion) don't trigger a pointless deletion attempt. Theafter_destroycallback runs after the DB row is removed but the in-memory object retains its attribute values, so readingtapas_xq_doc_idhere is safe.app/models/project.rbAdd
after_destroy :enqueue_tapas_xq_project_deletionand a private method:Note:
idis available on the in-memory object afterafter_destroyruns.Dependencies
DeleteFromTapasXqJobandDeleteProjectFromTapasXqJobmust exist firstTests
Add to
spec/models/core_file_spec.rbandspec/requests/core_files_spec.rbandspec/requests/projects_spec.rb. See testing plan doc for specific examples.