-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1294 from NEU-Libraries/feature/load_report_obj_a…
…nd_spec Feature/load report obj and spec
- Loading branch information
Showing
23 changed files
with
353 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.0.156 | ||
0.0.157 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.8.1 | ||
2.8.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
class Ingest < ApplicationRecord | ||
enum status: { pending: 0, completed: 1, failed: 2 } | ||
belongs_to :load_report | ||
|
||
enum :status, { pending: 0, completed: 1, failed: 2 } | ||
|
||
validates :pid, presence: true | ||
validates :xml_filename, presence: true | ||
validates :status, presence: true | ||
|
||
def self.create_from_spreadsheet_row(row) | ||
def self.create_from_spreadsheet_row(pid, file_name, load_report_id) | ||
create!( | ||
pid: row[0], | ||
xml_filename: row[1], | ||
status: :pending | ||
pid: pid, | ||
xml_filename: file_name, | ||
status: :pending, | ||
load_report: LoadReport.find(load_report_id) | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
class LoadReport < ApplicationRecord | ||
has_many :ingests | ||
|
||
enum :status, { in_progress: 0, completed: 1, failed: 2 } | ||
|
||
validates :status, presence: true | ||
|
||
def start_load | ||
update(status: :in_progress, started_at: Time.now) | ||
end | ||
|
||
def finish_load | ||
update(status: :completed, finished_at: Time.now) | ||
end | ||
|
||
def fail_load | ||
update(status: :failed, finished_at: Time.now) | ||
end | ||
|
||
def success_rate | ||
return 0 if ingests.empty? | ||
((ingests.completed.count.to_f / ingests.count.to_f) * 100).round(2) | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
%h2.py-3 | ||
Ingest Management | ||
|
||
.upload-form | ||
%h3.py-3 | ||
Upload ZIP File | ||
= form_tag loads_path, multipart: true do | ||
.input-group.mb-3 | ||
%input#file.form-control{name: "file", type: "file", accept: 'application/zip,application/x-zip-compressed'}/ | ||
= submit_tag "Upload", class: 'btn btn-primary' | ||
%div | ||
%h2.py-3 | ||
Load Reports | ||
%table.table | ||
%thead | ||
%tr | ||
%th Status | ||
%th Started At | ||
%th Finished At | ||
%th Success Rate | ||
%th View | ||
%tbody | ||
- @load_reports.each do |load_report| | ||
%tr | ||
%td= load_report.status | ||
%td= load_report.started_at | ||
%td= load_report.finished_at | ||
%td= load_report.success_rate | ||
%td | ||
%a.btn.btn-sm.btn-primary{:href => load_path(load_report.id)} View |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
%h2.py-3 | ||
Load Report | ||
%table.table | ||
%thead | ||
%tr | ||
%th PID | ||
%th XML Filename | ||
%th Status | ||
%th Created At | ||
%tbody | ||
- @load_report.ingests.each do |ingest| | ||
%tr | ||
%td= ingest.pid | ||
%td= ingest.xml_filename | ||
%td= ingest.status | ||
%td= ingest.created_at | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class CreateLoadReports < ActiveRecord::Migration[7.2] | ||
def change | ||
create_table :load_reports do |t| | ||
t.integer :status, null: false, default: 0 | ||
t.datetime :started_at | ||
t.datetime :finished_at | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.