Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

247 ingest report #249

Merged
merged 10 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
12 changes: 12 additions & 0 deletions app/controllers/mars_ingest_failures_controller.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions app/controllers/mars_ingests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions app/models/mars_ingest_failure.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class MarsIngestFailure < ActiveRecord::Base
end
1 change: 1 addition & 0 deletions app/services/mars_ingest_watcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 15 additions & 0 deletions app/views/mars_ingest_failures/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<% @page_title = t('mars_ingests.title', :application_name => application_name) %>

<div class="page-title-wrapper">
<h1 class="page-title">Mars Ingests</h1>
<% @mars_ingest_failures.each do |mif| %>

<div class="row">
<div class="col-md-12 collection-btn">
Manifest URL: <%= mif.manifest_url %><br>
Attempted At: <%= mif.created_at %><br>
<a href="/mars_ingest_failures/<%= mif.id %>">Error</a><br>
</div>
</div>
<% end %>
</div>
1 change: 1 addition & 0 deletions app/views/mars_ingest_failures/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= @mars_ingest_failure.error_text %>
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20210210213523_record_media_pim_id.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ class RecordMediaPimId < ActiveRecord::Migration[5.2]
def change
add_column :mars_ingest_items, :media_pim_id, :string
end
end
end
9 changes: 9 additions & 0 deletions db/migrate/20240310213523_create_mars_ingest_failures.rb
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions script/watch_folder.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# include it all
require_relative '../config/environment'
puts "what up yo!"
MarsIngestWatcher.run
20 changes: 15 additions & 5 deletions script/watch_folder.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
#!/usr/bin/env ruby
#!/bin/bash

# include it all
require_relative '../config/environment'
puts "what up yo!"
MarsIngestWatcher.run
# 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
Loading