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

Rework gbif cleanup #1220

Merged
merged 4 commits into from
Jul 26, 2024
Merged

Rework gbif cleanup #1220

merged 4 commits into from
Jul 26, 2024

Conversation

wendelfabianchinsamy
Copy link
Contributor

Purpose

closes: Add github issue that originated this PR

Approach

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.

@wendelfabianchinsamy wendelfabianchinsamy requested a review from a team July 25, 2024 15:34
event.destroy! if event.present?
# delete event records from mysql
sql = ActiveRecord::Base.sanitize_sql_array(["DELETE FROM events WHERE id IN (?)", ids])
ActiveRecord::Base.connection.execute(sql)
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 delete the events using raw query, we are skipping the after_commit on: [:destroy] callback.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ashwinisukale yes this is by design as I will be using the bulk api to delete the documents in the events index.


response = Event.query(query, filter.merge(page: { size: 1, cursor: [] }))

if response.size.positive?
Copy link
Contributor

Choose a reason for hiding this comment

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

we should verify if response.present? && response.respond_to?(:size) && response.size.positive? response present, incase of an error

while response.size.positive? && delete_count < max_delete_count
response = Event.query(query, filter.merge(page: { size: size, cursor: cursor }))

break unless response.size.positive?
Copy link
Contributor

Choose a reason for hiding this comment

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

we can make little readable by checking it like this break if response.size.zero?

Copy link
Contributor

@ashwinisukale ashwinisukale left a comment

Choose a reason for hiding this comment

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

looks good, there are some refactoring changes needed, but as you said we will be deleting this code so no need to worry on refactoring part.

Thanks,

@wendelfabianchinsamy wendelfabianchinsamy merged commit 1aa2e60 into master Jul 26, 2024
12 of 13 checks passed
@wendelfabianchinsamy wendelfabianchinsamy deleted the rework-gbif-cleanup branch July 26, 2024 10:51
Copy link

sentry-io bot commented Jul 30, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ SignalException: SIGHUP gbif_events:delete_gbif_events View Issue

Did you find this useful? React with a 👍 or 👎

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.

2 participants