Skip to content
Snippets Groups Projects
Verified Commit 7132f43f authored by jindra12's avatar jindra12
Browse files

Correct tag count

parent 4e8ba248
No related branches found
No related tags found
2 merge requests!816Release,!801Prepare basic shared tags
......@@ -4,8 +4,8 @@ from functools import reduce
from django.apps import apps
from django.db import models
from django.db.models import F, Q
from django.db.models.expressions import F, Value
from django.db.models import Q
from django.db.models.expressions import ExpressionWrapper, F, Value
from django.db.models.functions import Coalesce
from django.utils import timezone
from modelcluster.fields import ParentalKey, ParentalManyToManyField
......@@ -313,7 +313,10 @@ class ArticlesMixin(models.Model):
def evaluate_page_query(self, results):
return list(
reduce(
lambda unique, item: unique | {f"{item['union_page_ptr_id']}": item},
lambda unique, item: unique
if item["union_page_ptr_id"] in unique
and "union_shared_from_id" in item
else unique | {f"{item['union_page_ptr_id']}": item},
list(results),
{},
).values()
......@@ -564,11 +567,15 @@ class ArticlesMixin(models.Model):
articles: list,
tags_model_query=None,
):
own_page_type = self.determine_page_type()
get_ids_by_page_type = lambda page_type: list(
map(
lambda article: article.page_ptr.id,
filter(
lambda article: article.shared_type == page_type,
lambda article: article.shared_type == page_type
or (
article.shared_type is None and own_page_type.value == page_type
),
articles,
),
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment