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

Rewrite tag deletion #2564

Merged
merged 2 commits into from
Oct 12, 2020
Merged

Rewrite tag deletion #2564

merged 2 commits into from
Oct 12, 2020

Conversation

AndiPersti
Copy link
Contributor

This PR closes #2563.

The problem was that the table method for removing a tag used deleteAll() which doesn't trigger the afterDelete event. But we use this event to update the attributes of the search index.

'deleteAll()' doesn't trigger the 'afterDelete' event which we
need for updating the search index.
@AndiPersti AndiPersti added this to the 2020-10-04 milestone Oct 2, 2020
public function removeTagFromSentence($tagId, $sentenceId) {
$entity = $this->find()
->where(['tag_id' => $tagId, 'sentence_id' => $sentenceId])
->first();
Copy link
Member

Choose a reason for hiding this comment

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

This won’t work for tags that have been applied more than once on the same sentence. As far as I remember, this only happens when Horus merges two sentences having the same tag. See by yourself:

select count(*) as c, tag_id, sentence_id from tags_sentences group by tag_id, sentence_id having c > 1;
+---+--------+-------------+
| c | tag_id | sentence_id |
+---+--------+-------------+
| 2 |      2 |      482049 |
| 2 |      5 |     2337281 |
| 2 |      5 |     3214286 |
...
+---+--------+-------------+
4024 rows in set (1.481 sec)

Copy link
Member

Choose a reason for hiding this comment

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

Just to explain this mess. At the time Horus was created, we were aware of these "duplicate" tags and we (well, I) chose to adapt the way tags are displayed (in the sentence page and in the "sentences tagged as x" listing) to hide these duplicates (as opposed to deleting them) in order not to loose the information that two users had tagged that sentence. Looking back, I think it was a mistake because it produced a number of new bugs and added no real value in the end.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for reminding me of this Horus bug.

@AndiPersti AndiPersti removed this from the 2020-10-04 milestone Oct 5, 2020
Due to a bug in Horus there may be more than one tagId-sentenceId pair
in the database.
@AndiPersti AndiPersti added this to the 2020-10-11 milestone Oct 6, 2020
@AndiPersti AndiPersti merged commit 6b4aafe into Tatoeba:dev Oct 12, 2020
@AndiPersti AndiPersti deleted the issue-2563 branch October 12, 2020 12:49
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.

Sentences with tags still appear in custom queries even the tag is removed
2 participants