Skip to content

Conversation

@candemiralp
Copy link
Contributor

Description

This PR implements the data clean-up functionality for already submitted events or events older than 45 days.

@candemiralp candemiralp requested a review from a team as a code owner January 5, 2026 10:49
@candemiralp candemiralp changed the title Implement clean up functionality Implement data clean up functionality Jan 5, 2026
@candemiralp candemiralp changed the title Implement data clean up functionality Implement data clean-up functionality Jan 5, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @candemiralp, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a robust data cleanup mechanism for analytics events. It establishes a new cron job that periodically purges events that are either older than 45 days or have already been processed, thereby optimizing database performance and storage by removing stale data.

Highlights

  • New Cron Job for Analytics Event Cleanup: A new cron job, adyen_payment_clean_up_analytics_events, has been introduced to automatically remove old analytics event data from the database.
  • Cleanup Logic Implementation: The cron job identifies and targets analytics events for deletion if they are older than 45 days or have already been processed (marked with a 'done' status).
  • Efficient Batch Deletion: A new deleteByIds method has been added to the AnalyticsEvent resource model, enabling efficient bulk deletion of multiple records in a single database operation.
  • Configurable Cleanup Batch Size: A CLEAN_UP_BATCH_SIZE constant (set to 5000) has been introduced to control the number of records processed per cleanup batch, optimizing performance.
  • Improved Translation String Formatting: Minor updates were made to error messages in CheckoutAnalytics.php to use Magento's preferred %1 placeholder for translatable strings, ensuring proper localization.
  • Comprehensive Unit Tests: New unit tests have been added for the AnalyticsEventsCleanUp cron job, the analyticsEventsToCleanUp collection method, and the deleteByIds resource model method, ensuring the reliability and correctness of the new functionality.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a data clean-up functionality for analytics events, which is a great addition for maintaining the database. The implementation includes a new cron job, resource model methods for deletion, and collection filtering. The accompanying unit tests are thorough and cover various scenarios.

My review includes a few suggestions to improve performance and maintainability:

  • Optimizing the database query in the cron job to avoid an unnecessary COUNT query.
  • Refactoring the delete method in the resource model for better readability and simplicity.
  • Replacing a hardcoded value with a constant to improve maintainability.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 5, 2026

@candemiralp candemiralp merged commit 09ecab0 into feature/reliability Jan 6, 2026
5 of 6 checks passed
@candemiralp candemiralp deleted the reliability-cleanup branch January 6, 2026 08:03
candemiralp added a commit that referenced this pull request Jan 6, 2026
* [ECP-9414] Generate event dispatcher/observer mechanism for reliability events

* [ECP-9413] Create CheckoutAnalytics helper class

* [ECP-9750] Implement configuration field for metrics data collection (#3023)

* [ECP-9745] Update the DB schema and refactor related classes (#3024)

* [ECP-9745] Update the DB schema and refactor related classes

* [ECP-9745] Update argument type declarations

* [ECP-9745] Update example event handlers

* [ECP-9745] Fix model argument

* [ECP-9746] Refactoring Checkout Analytics event requests (#3079)

* [ECP-9751] Implement a cronjob to submit pending events (#3087)

* [ECP-9751] Implement a cronjob to submit pending events

* [ECP-9751] Enable main workflow on the feature branch

* [ECP-9751] Write unit tests

* [ECP-9751] Update tests

* [ECP-9417] Implement event dispatchers (#3113)

* [ECP-9417] Implement analytics event dispatchers

* [ECP-9417] Add try-catch block

* [ECP-9727] Implement an event dispatcher for plugin installation event (#3114)

* [ECP-9727] Implement an event dispatcher for plugin installation event

* [ECP-9727] Add missing module setup end flag

* [ECP-9835] Add the version field to the adyen_analytics_event entity (#3138)

* [ECP-9835] Add version field to the dbschema and entity definition

* [ECP-9835] Dispatch events only for Adyen namespace

* [ECP-9835] Group entities by version and submit them separately

* [ECP-9835] Put the feature behind a config flag

* Update SubmitAnalyticsEvents.php

* Add unit tests (#3207)

* Optimize rest events to intercept

* Write unit tests

* Enable workflows

* Fix static code issues

* Fix several issues

* Remove unexpectedEnd event from the info event batch

* Truncate the topic if necessary

* Implement data clean-up functionality (#3209)

* Implement clean up functionality

* Prevent the duplicate db query

* Update .github/workflows/e2e-test.yml

* Update .github/workflows/main.yml

* Update .github/workflows/main.yml

* Reformat the message in case of errors

---------

Co-authored-by: khushboos <[email protected]>
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.

3 participants