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

More detailed file status #66

Merged
merged 1 commit into from
Dec 12, 2019
Merged

More detailed file status #66

merged 1 commit into from
Dec 12, 2019

Conversation

little9
Copy link
Contributor

@little9 little9 commented Nov 14, 2019

This adds a status field to PreIngestFiles that
defaults to 'preingest'.

The AttachFilesToWorkJob class is preprended with
logic that updates the status to 'attached'.

The logic requires that deduplication_key is present in the
CSV so that field is added to the default mapper and validator.

There is a helper which outputs a success icon (a green checkmark) if
the PreIngestFile has an 'attached' status. This is used for the
PreIngestWork if all the statuses for the PreIngestFile are 'attached'.

Copy link
Contributor

@mark-dce mark-dce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all makes sense. I added a few specific comments, but the overall shape and idea looks good.

def status_icon(status)
# rubocop:disable Rails/OutputSafety
return "<span class='glyphicon glyphicon-ok-sign text-success'></span>".html_safe if status == 'attached'
"<span class='glyphicon glyphicon-question-sign'></span>".html_safe
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this idiom preferred (return if)? Otherwise if there are just two equal options (this or that) I find it a little easier to read if/else structures.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we use icons semantically in this way, we should generally include an aria-label see https://fontawesome.com/how-to-use/on-the-web/other-topics/accessibility

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mark-dce There's a rubocop/bixby rule we have for this: https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/GuardClause

https://github.com/samvera-labs/bixby/blob/master/bixby_default.yml#L129

It will fail if you use an if / else block when you could have used a guard clause.

@@ -0,0 +1 @@
AttachFilesToWorkJob.prepend(AttachFilesToWorkJobPrepends)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use this same strategy to add additional logging to Hyrax background jobs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, and doing that way avoids needing to override it which could be problematic if someone is already overriding a job.

@@ -25,6 +25,9 @@ def self.included(work)
work.property :related_url, predicate: ::RDF::RDFS.seeAlso
work.property :bibliographic_citation, predicate: ::RDF::Vocab::DC.bibliographicCitation
work.property :source, predicate: ::RDF::Vocab::DC.source

# From Zizia
work.property :deduplication_key, predicate: 'http://metadata.example.com/vocab/predicates#deduplicationKey'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we just want to implement a primary_id and find a better predicate. It feels like that's what most adopters are going to want anyway.

How about :RDF::VOCAB::BF2::identifiedBy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding a more specific predicate may ultimately be confusing because then institutions may be tempted to use it for some other purpose. Right now the the deduplication_key is something that's only used for grouping the Work and FileSets during the import.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the predicate to ::RDF::VOCAB::BF2.identifiedBy, but I really think we should keep using the name deduplication_key since Emory is already using that.

@little9 little9 force-pushed the individual-file-status branch 2 times, most recently from 18eed87 to 5520940 Compare December 10, 2019 19:45
@little9 little9 marked this pull request as ready for review December 10, 2019 19:49
@little9 little9 force-pushed the individual-file-status branch 2 times, most recently from d066b75 to 661545d Compare December 10, 2019 20:20
@little9
Copy link
Contributor Author

little9 commented Dec 10, 2019

filestatus

@little9 little9 force-pushed the individual-file-status branch 5 times, most recently from fc797b1 to 86000db Compare December 11, 2019 17:09
This adds a status field to `PreIngestFile`s and
`PreIngestWorks` that defaults to 'preingest'.

The `ContentDepositEventJob` and `FileSetAttachedEventJob` classes
are preprended with logic that updates their status to 'attached'.

The logic requires that `deduplication_key` is present in the
CSV so that field is added to the default mapper and validator.

There is a helper which outputs a success icon (a green checkmark)
if a `PreIngestFile` or `PreIngestWork` has an 'attached' status.
@mark-dce mark-dce merged commit 14ff29a into master Dec 12, 2019
@mark-dce mark-dce deleted the individual-file-status branch December 30, 2019 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants