diff --git a/Gemfile b/Gemfile index b3b0bfcb6..f470c166b 100644 --- a/Gemfile +++ b/Gemfile @@ -156,10 +156,10 @@ group :test do end # just to make sure they're the same -group :production, :qa do +# group :production, :qa do gem 'google-analytics-rails', '1.1.0' gem 'lograge' -end +# end # Install the bundle --with aws when running on Amazon Elastic Beanstalk group :aws, optional: true do @@ -175,14 +175,15 @@ group :zoom, optional: true do end # Install the bundle --with postgres if using postgresql as the database backend -group :postgres, optional: true do +# group :postgres, optional: true do gem 'pg' -end +# end # Install the bundle --with mysql if using mysql as the database backend group :mysql, optional: true do gem 'mysql2' end -extra_gems = File.expand_path("../Gemfile.local", __FILE__) -eval File.read(extra_gems) if File.exist?(extra_gems) +# no thanks +# extra_gems = File.expand_path("../Gemfile.local", __FILE__) +# eval File.read(extra_gems) if File.exist?(extra_gems) diff --git a/app/controllers/mars_ingest_failures_controller.rb b/app/controllers/mars_ingest_failures_controller.rb new file mode 100644 index 000000000..203a1be77 --- /dev/null +++ b/app/controllers/mars_ingest_failures_controller.rb @@ -0,0 +1,12 @@ +class MarsIngestFailuresController < ApplicationController + before_action :authenticate_user! + + def index + @mars_ingest_failures = MarsIngestFailure.order(created_at: :desc).all + end + + def show + @mars_ingest_failure = MarsIngestFailure.find(params[:id]) + render 'show', layout: false, content_type: 'text/plain' + end +end diff --git a/app/controllers/mars_ingests_controller.rb b/app/controllers/mars_ingests_controller.rb index c5ceb5105..09313541b 100644 --- a/app/controllers/mars_ingests_controller.rb +++ b/app/controllers/mars_ingests_controller.rb @@ -34,6 +34,8 @@ def create render json: { id: @mars_ingest.id }, status: 200 else Rails.logger.info "MarsIngest could not be saved: (#{ @mars_ingest.errors.messages.values.flatten })" + # save error text! this is only for ingests manually created through the UI + MarsIngestFailure.create(manifest_url: @mars_ingest.manifest_url, error_text: @mars_ingest.errors.messages.values.flatten) render json: { errors: @mars_ingest.errors.messages.values.flatten }, status: 422 end rescue => e diff --git a/app/models/mars_ingest_failure.rb b/app/models/mars_ingest_failure.rb new file mode 100644 index 000000000..a0ec81729 --- /dev/null +++ b/app/models/mars_ingest_failure.rb @@ -0,0 +1,2 @@ +class MarsIngestFailure < ActiveRecord::Base +end diff --git a/app/services/mars_ingest_watcher.rb b/app/services/mars_ingest_watcher.rb index 451ee98cd..fd2196b2b 100644 --- a/app/services/mars_ingest_watcher.rb +++ b/app/services/mars_ingest_watcher.rb @@ -79,6 +79,7 @@ def self.run_manifest(key) end else puts "Darn! Manifest invalid! #{mi.errors.messages.values.flatten}" + MarsIngestFailure.create(manifest_url: mi.manifest_url, error_text: mi.errors.messages.values.flatten) end end diff --git a/app/views/mars_ingest_failures/index.html.erb b/app/views/mars_ingest_failures/index.html.erb new file mode 100644 index 000000000..60d7608e1 --- /dev/null +++ b/app/views/mars_ingest_failures/index.html.erb @@ -0,0 +1,15 @@ +<% @page_title = t('mars_ingests.title', :application_name => application_name) %> + +
+

Mars Ingests

+ <% @mars_ingest_failures.each do |mif| %> + +
+
+ Manifest URL: <%= mif.manifest_url %>
+ Attempted At: <%= mif.created_at %>
+ Error
+
+
+ <% end %> +
diff --git a/app/views/mars_ingest_failures/show.html.erb b/app/views/mars_ingest_failures/show.html.erb new file mode 100644 index 000000000..0393e80e6 --- /dev/null +++ b/app/views/mars_ingest_failures/show.html.erb @@ -0,0 +1 @@ +<%= @mars_ingest_failure.error_text %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 6d0cf15e8..4e988162d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -96,6 +96,7 @@ end resources :mars_ingests, only: [:index, :show, :create] + resources :mars_ingest_failures, only: [:index, :show, :create] resources :media_objects, except: [:create, :update] do member do diff --git a/db/migrate/20210210213523_record_media_pim_id.rb b/db/migrate/20210210213523_record_media_pim_id.rb index cff93e11d..ba25e390c 100644 --- a/db/migrate/20210210213523_record_media_pim_id.rb +++ b/db/migrate/20210210213523_record_media_pim_id.rb @@ -2,4 +2,4 @@ class RecordMediaPimId < ActiveRecord::Migration[5.2] def change add_column :mars_ingest_items, :media_pim_id, :string end -end +end \ No newline at end of file diff --git a/db/migrate/20240310213523_create_mars_ingest_failures.rb b/db/migrate/20240310213523_create_mars_ingest_failures.rb new file mode 100644 index 000000000..7709d1672 --- /dev/null +++ b/db/migrate/20240310213523_create_mars_ingest_failures.rb @@ -0,0 +1,9 @@ +class CreateMarsIngestFailures < ActiveRecord::Migration[5.2] + def change + create_table :mars_ingest_failures do |t| + t.text :error_text + t.text :manifest_url + t.timestamps + end + end +end diff --git a/script/watch_folder.rb b/script/watch_folder.rb new file mode 100644 index 000000000..bb300a1c1 --- /dev/null +++ b/script/watch_folder.rb @@ -0,0 +1,4 @@ +# include it all +require_relative '../config/environment' +puts "what up yo!" +MarsIngestWatcher.run diff --git a/script/watch_folder.sh b/script/watch_folder.sh old mode 100644 new mode 100755 index 935df55c3..d246a1623 --- a/script/watch_folder.sh +++ b/script/watch_folder.sh @@ -1,6 +1,16 @@ -#!/usr/bin/env ruby +#!/bin/bash -# include it all -require_relative '../config/environment' -puts "what up yo!" -MarsIngestWatcher.run \ No newline at end of file +# get em +all=$(cat /proc/1/environ) +# split em +vars=$(echo $all | tr "\0" "\n") +for var in $vars +do + # export em + piece1 = $(echo $var | tr "=", "\n")[0] + piece2 = $(echo $var | tr "=", "\n")[1] + export `${piece1}=${piece2}` +done + +# ooh ah so nice +bundle exec ruby script/watch_folder.rb