Add a CLI command and a cronjob to detect duplicated translations - #180
Add a CLI command and a cronjob to detect duplicated translations#180amieiro wants to merge 5 commits into
Conversation
akirk
left a comment
There was a problem hiding this comment.
I like the approach, I think better naming would make it easier to comprehend
Command name: detect-duplicate-translations -> duplicate-translations Parameter name: --update -> --fix
Print: - translation_id - date_added - date_modified - user_id - user_id_last_modified - translation
|
@akirk I have made the changes you have suggested in the WP-CLI command interface and the improvement to the update SQL query. |
…ions See #180 git-svn-id: https://meta.svn.wordpress.org/sites/trunk@12985 74240141-8908-4e6f-9713-ba540dce6ec7
|
I close this PR, as it has been deployed. Finally, the notifications are sent to Matrix. |
|
@amieiro , why set them on old right away? What if the wrong one is set to old. Maybe set them fuzzy so PTE/GTE's can decide ;) |
|
@NekoJonez We had a lot of translations with duplications: around 42,000, so if we put this as fuzzy, the work would be very big for the GTE. |
…ions See WordPress#180 git-svn-id: https://meta.svn.wordpress.org/sites/trunk@12985 74240141-8908-4e6f-9713-ba540dce6ec7
Problem
Last week, while I was developing an improvement to be able to make bulk updates to the translations in the consistency tool, I made a mistake and set some translations as "current" for the same original.
I knew we have some translations in the same situation, maybe related with some translations created while the original strings are imported.
I made a script to detect the number of duplicates, and we have more than 42,000 duplicates in 31,600,000 translation sets (around 0.13 % of the translations).
We have different situations:
date_addedanddate_modified. We have rows, at least, between 2015 and in 2023:date_modifiedbut differentdate_added:Solution
This PR adds:
currentstatus. It will send a notification to a Slack channel.To detect duplicated translations, the code looks for translations with the same
original_idandtranslation_set_idand the translation status set tocurrent.To update these duplicated translations, the code updates all the duplicates, setting:
statustoold.user_id_last_modifiedtoNULL, reflecting a translation updated by a bot.date_modifiedto thecurrent date time.Only one duplicated translation remains without been updated:
date_modifiedvalue).date_modifiedvalue, the code selects the one with the highestid(the last introduced in the system).Cronjob
The cronjob checks once a day if we have some duplicated translations in the database and sends a notification to the #dotorg channel (Slack, "Making WordPress" instance).
These are the screenshots that this cronjob will send:
Command
The command will allow updating the duplicated translations, so we will be able to solve this problem by hand. If this problem persists, we will be able to update these duplicated translations in the cronjob (This has to be done in a different PR).
To use this command, you have to execute in the CLI:
This command has 4 flags:
--fix: Updates the duplicates, setting all translations to old except the last one.--notify: Notifies the duplicates in Slack.--verbose: Shows the results in the CLI.--print-sql: Shows the SQL queries to show and to update the duplicate entries.Some CLI examples: