mirror of
https://github.com/wallabag/wallabag.git
synced 2025-07-27 17:28:39 +00:00
Avoid tag duplication when tagging all articles
Mostly when the tag doesn’t yet exist. It was created each time it matche the rule… glups.
This commit is contained in:
parent
4d318f3755
commit
b4fcd60e7f
1 changed files with 7 additions and 1 deletions
|
@ -55,6 +55,7 @@ class RuleBasedTagger
|
||||||
{
|
{
|
||||||
$rules = $this->getRulesForUser($user);
|
$rules = $this->getRulesForUser($user);
|
||||||
$entries = [];
|
$entries = [];
|
||||||
|
$tagsCache = [];
|
||||||
|
|
||||||
foreach ($rules as $rule) {
|
foreach ($rules as $rule) {
|
||||||
$qb = $this->entryRepository->getBuilderForAllByUser($user->getId());
|
$qb = $this->entryRepository->getBuilderForAllByUser($user->getId());
|
||||||
|
@ -62,7 +63,12 @@ class RuleBasedTagger
|
||||||
|
|
||||||
foreach ($entries as $entry) {
|
foreach ($entries as $entry) {
|
||||||
foreach ($rule->getTags() as $label) {
|
foreach ($rule->getTags() as $label) {
|
||||||
$tag = $this->getTag($label);
|
// avoid new tag duplicate by manually caching them
|
||||||
|
if (!isset($tagsCache[$label])) {
|
||||||
|
$tagsCache[$label] = $this->getTag($label);
|
||||||
|
}
|
||||||
|
|
||||||
|
$tag = $tagsCache[$label];
|
||||||
|
|
||||||
$entry->addTag($tag);
|
$entry->addTag($tag);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue