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

Fix #19927: Refactor DB message saving mechanism #19934

Merged
merged 7 commits into from
Oct 16, 2023

Conversation

atrandafir
Copy link
Contributor

@atrandafir atrandafir commented Aug 19, 2023

  • Split into two parts, first for handling source table and second for handling message table
  • Fix bug to not break when adding new string and new language at the same time
  • Rebuild missing rows into messages table
  • Remove obsolete languages rows from message table
Q A
Is bugfix? ✔️
New feature?
Breaks BC?
Fixed issues #19927

Example output, adding one string and one language:

Extracting messages from example\project\requirements.php...

UPDATING DB

SOURCE MESSAGE TABLE

Inserting new messages...1 saved.
Deleting obsoleted messages...Nothing obsoleted...skipped.


MESSAGE TABLE

Generating missing rows...1 for es, 1 for ca, 1 for en, 254 for af.
Dropping unused languages...Nothing to do.

Example output, removing one language:

Extracting messages from example\project\requirements.php...

UPDATING DB

SOURCE MESSAGE TABLE

Inserting new messages...Nothing to save.
Deleting obsoleted messages...Nothing obsoleted...skipped.


MESSAGE TABLE

Generating missing rows...Nothing to do.
Dropping unused languages...removed 254 rows for af.	

@what-the-diff
Copy link

what-the-diff bot commented Aug 19, 2023

PR Summary

  • Enhanced Console Feedback
    Our solution now provides better and more descriptive feedback during the processing phase. Feedback such as "UPDATING DB", "SOURCE MESSAGE TABLE", "Inserting new messages...", and so on, will now be displayed on the system console when the application is running.

  • Removal of Unused Variables
    We've removed variables like $currentLanguages and $savedFlag that were previously used for handling missing languages and checking if anything was saved. This simplifies code and improves overall efficiency.

  • Improved Message Insertion Process
    The old code for inserting new messages into the source message table has been refined. Now it is all about direct message insertion with no more language handling involved in this process.

  • Elimination of Redundant Checks
    The checks for missing languages and updating of the messages in the message table have been removed, making the code cleaner and easier to understand. Similarly, removed return statement that was not needed.

  • Feedback on Operation Success and Failure
    The system now provides feedback with the actual number of messages saved or an update on a scenario when there's nothing to save. This gives you a sense of how many entries were affected during the process.

  • Refinement of Obsoleted Messages Deletion
    We reimplemented the code for deleting obsoleted messages to use more practical data structures that optimize performance and memory use.

  • Improved Handling of Unused Languages
    The code now checks for unused languages in the message table and automatically deletes them. This action also generates missing rows for each language where needed.

  • Detailed Output for Operations on Missing Rows and Unused Languages
    The system will now display precise information on actions taken regarding the generation of missing rows and dropping unused languages from the message table. This helps keep track of the processes carried out on the data.

@codecov
Copy link

codecov bot commented Aug 19, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (5a4c048) 48.95% compared to head (8486e87) 48.96%.

❗ Current head 8486e87 differs from pull request most recent head 273f149. Consider uploading reports for the commit 273f149 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #19934      +/-   ##
==========================================
+ Coverage   48.95%   48.96%   +0.01%     
==========================================
  Files         445      445              
  Lines       42826    42834       +8     
==========================================
+ Hits        20964    20973       +9     
+ Misses      21862    21861       -1     
Files Coverage Δ
...ramework/console/controllers/MessageController.php 85.07% <100.00%> (+0.65%) ⬆️

... and 4 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@samdark samdark added the status:code review The pull request needs review. label Aug 26, 2023
@samdark samdark requested review from a team August 26, 2023 04:05
@samdark
Copy link
Member

samdark commented Aug 26, 2023

@yiisoft/yii2, @yiisoft/reviewers need your help reviewing this pull request.

@atrandafir is that possible to add a line for CHANGELOG? Easy thing required for merge.

@samdark samdark added this to the 2.0.50 milestone Oct 12, 2023
framework/console/controllers/MessageController.php Outdated Show resolved Hide resolved
framework/console/controllers/MessageController.php Outdated Show resolved Hide resolved
framework/console/controllers/MessageController.php Outdated Show resolved Hide resolved
@samdark samdark merged commit 961a952 into yiisoft:master Oct 16, 2023
47 checks passed
@samdark
Copy link
Member

samdark commented Oct 16, 2023

Thank you!

@atrandafir
Copy link
Contributor Author

Happy I could contribute with something!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:code review The pull request needs review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants