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

Allow events to trigger on specific conditions #1052

Merged
merged 6 commits into from
Dec 14, 2023
Merged

Conversation

ashwinisukale
Copy link
Contributor

@ashwinisukale ashwinisukale commented Dec 6, 2023

Purpose

Events not created when DOI first created in registered or draft state

closes: datacite/datacite#1710

Approach

Events should be created at following conditions,

  • When we create a DOI directly with findable state
  • When state is findable and there is an update in any of these fields related_identifiers, creators, funding_references
  • When we change DOI state from any other state to findable

Open Questions and Pre-Merge TODOs

Learning

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

  • New feature (non-breaking change which adds functionality)

  • Breaking change (fix or feature that would cause existing functionality to change)

Reviewer, please remember our guidelines:

  • Be humble in the language and feedback you give, ask don't tell.
  • Consider using positive language as opposed to neutral when offering feedback. This is to avoid the negative bias that can occur with neutral language appearing negative.
  • Offer suggestions on how to improve code e.g. simplification or expanding clarity.
  • Ensure you give reasons for the changes you are proposing.

@ashwinisukale ashwinisukale requested a review from a team December 6, 2023 11:38
@ashwinisukale ashwinisukale self-assigned this Dec 6, 2023
Copy link
Member

@digitaldogsbody digitaldogsbody left a comment

Choose a reason for hiding this comment

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

Great work Ashwini :)

Comment on lines +25 to +27
changed_attributes = saved_changes
relevant_changes = changed_attributes.keys & %w[related_identifiers creators funding_references aasm_state]
send_import_message(to_jsonapi) if relevant_changes.any?
Copy link
Member

Choose a reason for hiding this comment

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

I really like this refactor away from an ever-increasing list of boolean clauses, very elegant!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you @digitaldogsbody :)

Also saved_change_to_attribute? this method only execute when we have update call, so we never captured the create DOI call before because of this method checks.

We missed the events for the DOI which are created directly with findable state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

saved_changes will work for both create and update action.

@ashwinisukale ashwinisukale merged commit 97ee797 into master Dec 14, 2023
13 checks passed
@ashwinisukale ashwinisukale deleted the event_data_bug branch December 14, 2023 16:41
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.

Events not created when DOI first created in registered or draft state
4 participants